Skip to content

Commit

Permalink
Used standard traits for deallocating user-defined function
Browse files Browse the repository at this point in the history
  • Loading branch information
trueqbit committed Nov 18, 2023
1 parent 0ca2015 commit 6715ffc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions dev/udf_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ namespace sqlite_orm {
struct destruct_only_deleter {
template<class UDF>
void operator()(UDF* f) const noexcept {
f->~UDF();
std::allocator<UDF> allocator;
using traits = std::allocator_traits<decltype(allocator)>;
traits::destroy(allocator, f);
}
};

Expand All @@ -41,10 +43,10 @@ namespace sqlite_orm {
final_call_fn_t finalAggregateCall;

const xdestroy_fn_t udfDeallocate;
// flag whether the UDF has been udfConstructed at `udfHandle`;
// flag whether the UDF has been constructed at `udfHandle`;
// necessary for aggregation operations
bool udfConstructed;
// pointer to memory for UDF
// pointer to memory space for UDF
void* const udfHandle;

~udf_proxy() {
Expand Down
8 changes: 5 additions & 3 deletions include/sqlite_orm/sqlite_orm.h
Original file line number Diff line number Diff line change
Expand Up @@ -14867,7 +14867,9 @@ namespace sqlite_orm {
struct destruct_only_deleter {
template<class UDF>
void operator()(UDF* f) const noexcept {
f->~UDF();
std::allocator<UDF> allocator;
using traits = std::allocator_traits<decltype(allocator)>;
traits::destroy(allocator, f);
}
};

Expand All @@ -14879,10 +14881,10 @@ namespace sqlite_orm {
final_call_fn_t finalAggregateCall;

const xdestroy_fn_t udfDeallocate;
// flag whether the UDF has been udfConstructed at `udfHandle`;
// flag whether the UDF has been constructed at `udfHandle`;
// necessary for aggregation operations
bool udfConstructed;
// pointer to memory for UDF
// pointer to memory space for UDF
void* const udfHandle;

~udf_proxy() {
Expand Down

0 comments on commit 6715ffc

Please sign in to comment.