Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion be/src/vec/common/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@
#if defined(USE_JEMALLOC)
#include <jemalloc/jemalloc.h>
#endif // defined(USE_JEMALLOC)

#ifdef __APPLE__
#include <malloc/malloc.h>
#define GET_MALLOC_SIZE(ptr) malloc_size(ptr)
#else
#include <malloc.h>
#define GET_MALLOC_SIZE(ptr) malloc_usable_size(ptr)
#endif
#include <stdint.h>
#include <string.h>

Expand Down Expand Up @@ -64,6 +71,14 @@
#define MAP_ANONYMOUS MAP_ANON
#endif

#ifndef __THROW
#if __cplusplus
#define __THROW noexcept
#else
#define __THROW
#endif
#endif

static constexpr size_t MMAP_MIN_ALIGNMENT = 4096;
static constexpr size_t MALLOC_MIN_ALIGNMENT = 8;

Expand Down Expand Up @@ -106,7 +121,7 @@ class ORCMemoryAllocator {

static constexpr bool need_record_actual_size() { return true; }

static size_t allocated_size(void* ptr) { return malloc_usable_size(ptr); }
static size_t allocated_size(void* ptr) { return GET_MALLOC_SIZE(ptr); }

static int posix_memalign(void** ptr, size_t alignment, size_t size) __THROW {
return ::posix_memalign(ptr, alignment, size);
Expand Down