11# define UNUSED(x) UNUSED_##x __attribute__((__unused__))
12#elif defined(_MSC_VER)
14# define UNUSED(x) UNUSED_##x __pragma(warning(suppress : 4100))
16# define UNUSED(x) UNUSED_##x
19#undef HAVE_MALLOC_STATS
20#define USE_MALLOC_USABLE_SIZE
22#if defined(HAVE_MALLOC_STATS_H)
24# define HAVE_MALLOC_STATS
25#elif defined(__FreeBSD__)
26# include <malloc_np.h>
27#elif defined(__NetBSD__) || defined(__OpenBSD__)
28# undef USE_MALLOC_USABLE_SIZE
29#elif defined(__APPLE__)
30# include <malloc/malloc.h>
31# define malloc_usable_size malloc_size
34# define malloc_usable_size _msize
35#elif defined(__HAIKU__)
37size_t malloc_usable_size(
void *
ptr);
39# pragma message "We don't know how to use malloc_usable_size on your platform"
40# undef USE_MALLOC_USABLE_SIZE
43#define SIZET_FORMAT "%zu"
44#define SIZET_ARG(a) ((size_t)(a))
46#define SIZET_ALIGN_4(len) ((len + 3) & ~(size_t)3)
49# define LIKELY(x) __builtin_expect(!!(x), 1)
50# define UNLIKELY(x) __builtin_expect(!!(x), 0)
53# define UNLIKELY(x) (x)
56#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
67# define MEM_INLINE static __inline
69# define MEM_INLINE static inline
72#define IS_POW2(a) (((a) & ((a)-1)) == 0)
75#define MEMHEAD_ALIGN_PADDING(alignment) \
76 ((size_t)alignment - (sizeof(MemHeadAligned) % (size_t)alignment))
79#define MEMHEAD_REAL_PTR(memh) ((char *)memh - MEMHEAD_ALIGN_PADDING(memh->alignment))
83#define ALIGNED_MALLOC_MINIMUM_ALIGNMENT sizeof(void *)
136 mem_guarded::internal::AllocationType allocation_type)
189 mem_guarded::internal::AllocationType allocation_type)
#define ATTR_WARN_UNUSED_RESULT
#define ATTR_ALLOC_SIZE(...)
#define ATTR_NONNULL(...)
void * MEM_guarded_reallocN_id(void *vmemh, size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(2)
size_t memory_usage_current(void)
unsigned int MEM_guarded_get_memory_blocks_in_use(void)
void * MEM_lockfree_malloc_arrayN(size_t len, size_t size, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void * MEM_guarded_malloc_arrayN(size_t len, size_t size, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void * MEM_lockfree_dupallocN(const void *vmemh) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void MEM_lockfree_freeN(void *vmemh, mem_guarded::internal::AllocationType allocation_type)
void aligned_free(void *ptr)
void * MEM_guarded_recallocN_id(void *vmemh, size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(2)
void memory_usage_block_alloc(size_t size)
size_t MEM_guarded_allocN_len(const void *vmemh) ATTR_WARN_UNUSED_RESULT
void MEM_lockfree_reset_peak_memory(void)
void mem_lockfree_clearmemlist(void)
size_t MEM_guarded_get_peak_memory(void) ATTR_WARN_UNUSED_RESULT
void MEM_lockfree_name_ptr_set(void *vmemh, const char *str)
void * MEM_lockfree_mallocN_aligned(size_t len, size_t alignment, const char *str, mem_guarded::internal::AllocationType allocation_type) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(3)
void * MEM_lockfree_calloc_arrayN(size_t len, size_t size, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void MEM_lockfree_set_error_callback(void(*func)(const char *))
void MEM_guarded_set_error_callback(void(*func)(const char *))
void MEM_lockfree_printmemlist_stats(void)
size_t memory_usage_block_num(void)
void MEM_lockfree_set_memory_debug(void)
void memory_usage_init(void)
void MEM_guarded_printmemlist(void)
void MEM_guarded_printmemlist_pydict(void)
void MEM_guarded_callbackmemlist(void(*func)(void *))
void(* mem_clearmemlist)(void)
void * MEM_guarded_dupallocN(const void *vmemh) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
bool leak_detector_has_run
void * MEM_guarded_callocN(size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
bool MEM_guarded_consistency_check(void)
void * MEM_lockfree_reallocN_id(void *vmemh, size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(2)
bool MEM_lockfree_consistency_check(void)
void MEM_guarded_freeN(void *vmemh, mem_guarded::internal::AllocationType allocation_type)
void mem_guarded_clearmemlist(void)
void * MEM_lockfree_callocN(size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void memory_usage_block_free(size_t size)
void * MEM_guarded_calloc_arrayN(size_t len, size_t size, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void MEM_guarded_set_memory_debug(void)
void MEM_guarded_printmemlist_stats(void)
size_t memory_usage_peak(void)
void MEM_lockfree_printmemlist_pydict(void)
char free_after_leak_detection_message[]
void * MEM_lockfree_recallocN_id(void *vmemh, size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(2)
void memory_usage_peak_reset(void)
void * MEM_lockfree_mallocN(size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void MEM_lockfree_printmemlist(void)
void MEM_guarded_name_ptr_set(void *vmemh, const char *str)
size_t MEM_lockfree_allocN_len(const void *vmemh) ATTR_WARN_UNUSED_RESULT
const char * MEM_lockfree_name_ptr(void *vmemh)
void MEM_lockfree_callbackmemlist(void(*func)(void *))
void * aligned_malloc(size_t size, size_t alignment)
void * MEM_lockfree_calloc_arrayN_aligned(size_t len, size_t size, size_t alignment, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
const char * MEM_guarded_name_ptr(void *vmemh)
void MEM_guarded_reset_peak_memory(void)
size_t MEM_lockfree_get_memory_in_use(void)
size_t MEM_guarded_get_memory_in_use(void)
unsigned int MEM_lockfree_get_memory_blocks_in_use(void)
void * MEM_guarded_calloc_arrayN_aligned(size_t len, size_t size, size_t alignment, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
size_t MEM_lockfree_get_peak_memory(void) ATTR_WARN_UNUSED_RESULT
void * MEM_guarded_mallocN(size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void * MEM_guarded_mallocN_aligned(size_t len, size_t alignment, const char *str, mem_guarded::internal::AllocationType allocation_type) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(3)