24 #ifndef __MALLOCN_INTERN_H__
25 #define __MALLOCN_INTERN_H__
28 # define UNUSED(x) UNUSED_##x __attribute__((__unused__))
30 # define UNUSED(x) UNUSED_##x
33 #undef HAVE_MALLOC_STATS
34 #define USE_MALLOC_USABLE_SIZE
36 #if defined(__linux__) || (defined(__FreeBSD_kernel__) && !defined(__FreeBSD__)) || \
39 # define HAVE_MALLOC_STATS
40 #elif defined(__FreeBSD__)
41 # include <malloc_np.h>
42 #elif defined(__APPLE__)
43 # include <malloc/malloc.h>
44 # define malloc_usable_size malloc_size
47 # define malloc_usable_size _msize
48 #elif defined(__HAIKU__)
50 size_t malloc_usable_size(
void *
ptr);
52 # pragma message "We don't know how to use malloc_usable_size on your platform"
53 # undef USE_MALLOC_USABLE_SIZE
58 # define SIZET_FORMAT "%I64u"
59 # define SIZET_ARG(a) ((unsigned long long)(a))
61 # define SIZET_FORMAT "%lu"
62 # define SIZET_ARG(a) ((unsigned long)(a))
65 #define SIZET_ALIGN_4(len) ((len + 3) & ~(size_t)3)
68 # define LIKELY(x) __builtin_expect(!!(x), 1)
69 # define UNLIKELY(x) __builtin_expect(!!(x), 0)
71 # define LIKELY(x) (x)
72 # define UNLIKELY(x) (x)
75 #if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
87 # define MEM_INLINE static __inline
89 # define MEM_INLINE static inline
92 #define IS_POW2(a) (((a) & ((a)-1)) == 0)
95 #define MEMHEAD_ALIGN_PADDING(alignment) \
96 ((size_t)alignment - (sizeof(MemHeadAligned) % (size_t)alignment))
99 #define MEMHEAD_REAL_PTR(memh) ((char *)memh - MEMHEAD_ALIGN_PADDING(memh->alignment))
107 #define ALIGNED_MALLOC_MINIMUM_ALIGNMENT sizeof(void *)
#define ATTR_ALLOC_SIZE(...)
void BLI_kdtree_nd_() int BLI_kdtree_nd_() int BLI_kdtree_nd_() int BLI_kdtree_nd_() ATTR_WARN_UNUSED_RESULT
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
const char * MEM_guarded_name_ptr(void *vmemh)
unsigned int MEM_guarded_get_memory_blocks_in_use(void)
void * MEM_lockfree_mallocN_aligned(size_t len, size_t alignment, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(3)
void * MEM_guarded_dupallocN(const void *vmemh) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void * MEM_lockfree_mallocN(size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void aligned_free(void *ptr)
size_t MEM_guarded_allocN_len(const void *vmemh) ATTR_WARN_UNUSED_RESULT
void * MEM_lockfree_reallocN_id(void *vmemh, size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(2)
void MEM_lockfree_reset_peak_memory(void)
void * aligned_malloc(size_t size, size_t alignment)
size_t MEM_guarded_get_peak_memory(void) ATTR_WARN_UNUSED_RESULT
void * MEM_lockfree_recallocN_id(void *vmemh, size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(2)
void MEM_lockfree_set_error_callback(void(*func)(const char *))
void * MEM_guarded_reallocN_id(void *vmemh, size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(2)
void MEM_guarded_set_error_callback(void(*func)(const char *))
void MEM_lockfree_printmemlist_stats(void)
void MEM_lockfree_set_memory_debug(void)
void * MEM_guarded_callocN(size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
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_printmemlist(void)
void MEM_guarded_printmemlist_pydict(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 * 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_guarded_callbackmemlist(void(*func)(void *))
bool leak_detector_has_run
bool MEM_guarded_consistency_check(void)
bool MEM_lockfree_consistency_check(void)
void * MEM_lockfree_dupallocN(const void *vmemh) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
const char * MEM_lockfree_name_ptr(void *vmemh)
void MEM_guarded_set_memory_debug(void)
void ATTR_NONNULL(3)
Iterator New.
void MEM_guarded_printmemlist_stats(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_lockfree_printmemlist_pydict(void)
char free_after_leak_detection_message[]
void * MEM_guarded_mallocN_aligned(size_t len, size_t alignment, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(3)
void MEM_lockfree_printmemlist(void)
void MEM_lockfree_freeN(void *vmemh)
size_t MEM_lockfree_allocN_len(const void *vmemh) ATTR_WARN_UNUSED_RESULT
void MEM_lockfree_callbackmemlist(void(*func)(void *))
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_guarded_reset_peak_memory(void)
void * MEM_guarded_recallocN_id(void *vmemh, size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(2)
size_t MEM_lockfree_get_memory_in_use(void)
size_t MEM_guarded_get_memory_in_use(void)
void * MEM_guarded_mallocN(size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
unsigned int MEM_lockfree_get_memory_blocks_in_use(void)
size_t MEM_lockfree_get_peak_memory(void) ATTR_WARN_UNUSED_RESULT
void MEM_guarded_freeN(void *vmemh)