diff --git a/src/AggregateFunctions/QuantileTDigest.h b/src/AggregateFunctions/QuantileTDigest.h index 908b8795bf8..490abd5d134 100644 --- a/src/AggregateFunctions/QuantileTDigest.h +++ b/src/AggregateFunctions/QuantileTDigest.h @@ -114,7 +114,7 @@ class QuantileTDigest static constexpr size_t PART_SIZE_BITS = 8; using Transform = RadixSortFloatTransform; - using Allocator = RadixSortMallocAllocator; + using Allocator = RadixSortAllocator; /// The function to get the key from an array element. static Key & extractKey(Element & elem) { return elem.mean; } diff --git a/src/Common/RadixSort.h b/src/Common/RadixSort.h index 7ceb8569bd1..f490df3e4bb 100644 --- a/src/Common/RadixSort.h +++ b/src/Common/RadixSort.h @@ -35,16 +35,16 @@ /** Used as a template parameter. See below. */ -struct RadixSortMallocAllocator +struct RadixSortAllocator { void * allocate(size_t size) { - return malloc(size); + return ::operator new(size); } - void deallocate(void * ptr, size_t /*size*/) + void deallocate(void * ptr, size_t size) { - return free(ptr); + ::operator delete(ptr, size); } }; @@ -100,7 +100,7 @@ struct RadixSortFloatTraits /// An object with the functions allocate and deallocate. /// Can be used, for example, to allocate memory for a temporary array on the stack. /// To do this, the allocator itself is created on the stack. - using Allocator = RadixSortMallocAllocator; + using Allocator = RadixSortAllocator; /// The function to get the key from an array element. static Key & extractKey(Element & elem) { return elem; } @@ -139,7 +139,7 @@ struct RadixSortUIntTraits static constexpr size_t PART_SIZE_BITS = 8; using Transform = RadixSortIdentityTransform; - using Allocator = RadixSortMallocAllocator; + using Allocator = RadixSortAllocator; static Key & extractKey(Element & elem) { return elem; } static Result & extractResult(Element & elem) { return elem; } @@ -173,7 +173,7 @@ struct RadixSortIntTraits static constexpr size_t PART_SIZE_BITS = 8; using Transform = RadixSortSignedTransform; - using Allocator = RadixSortMallocAllocator; + using Allocator = RadixSortAllocator; static Key & extractKey(Element & elem) { return elem; } static Result & extractResult(Element & elem) { return elem; }