Blender  V3.3
Macros | Functions | Variables
mallocn_intern.h File Reference
#include <malloc.h>
#include "mallocn_inline.h"

Go to the source code of this file.

Macros

#define UNUSED(x)   UNUSED_##x
 
#define USE_MALLOC_USABLE_SIZE   /* internal, when we have malloc_usable_size() */
 
#define SIZET_FORMAT   "%zu"
 
#define SIZET_ARG(a)   ((size_t)(a))
 
#define SIZET_ALIGN_4(len)   ((len + 3) & ~(size_t)3)
 
#define LIKELY(x)   (x)
 
#define UNLIKELY(x)   (x)
 
#define MEM_INLINE   static inline
 
#define IS_POW2(a)   (((a) & ((a)-1)) == 0)
 
#define MEMHEAD_ALIGN_PADDING(alignment)    ((size_t)alignment - (sizeof(MemHeadAligned) % (size_t)alignment))
 
#define MEMHEAD_REAL_PTR(memh)   ((char *)memh - MEMHEAD_ALIGN_PADDING(memh->alignment))
 
#define ALIGNED_MALLOC_MINIMUM_ALIGNMENT   sizeof(void *)
 

Functions

voidaligned_malloc (size_t size, size_t alignment)
 
void aligned_free (void *ptr)
 
size_t MEM_lockfree_allocN_len (const void *vmemh) ATTR_WARN_UNUSED_RESULT
 
void MEM_lockfree_freeN (void *vmemh)
 
voidMEM_lockfree_dupallocN (const void *vmemh) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
 
voidMEM_lockfree_reallocN_id (void *vmemh, size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(2)
 
voidMEM_lockfree_recallocN_id (void *vmemh, size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(2)
 
voidMEM_lockfree_callocN (size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
 
voidMEM_lockfree_calloc_arrayN (size_t len, size_t size, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
 
void ATTR_NONNULL (3)
 Iterator New. More...
 
voidMEM_lockfree_mallocN (size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
 
voidMEM_lockfree_malloc_arrayN (size_t len, size_t size, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
 
voidMEM_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_lockfree_printmemlist_pydict (void)
 
void MEM_lockfree_printmemlist (void)
 
void MEM_lockfree_callbackmemlist (void(*func)(void *))
 
void MEM_lockfree_printmemlist_stats (void)
 
void MEM_lockfree_set_error_callback (void(*func)(const char *))
 
bool MEM_lockfree_consistency_check (void)
 
void MEM_lockfree_set_memory_debug (void)
 
size_t MEM_lockfree_get_memory_in_use (void)
 
unsigned int MEM_lockfree_get_memory_blocks_in_use (void)
 
void MEM_lockfree_reset_peak_memory (void)
 
size_t MEM_lockfree_get_peak_memory (void) ATTR_WARN_UNUSED_RESULT
 
const char * MEM_lockfree_name_ptr (void *vmemh)
 
size_t MEM_guarded_allocN_len (const void *vmemh) ATTR_WARN_UNUSED_RESULT
 
void MEM_guarded_freeN (void *vmemh)
 
voidMEM_guarded_dupallocN (const void *vmemh) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
 
voidMEM_guarded_reallocN_id (void *vmemh, size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(2)
 
voidMEM_guarded_recallocN_id (void *vmemh, size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(2)
 
voidMEM_guarded_callocN (size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
 
voidMEM_guarded_calloc_arrayN (size_t len, size_t size, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
 
voidMEM_guarded_mallocN (size_t len, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
 
voidMEM_guarded_malloc_arrayN (size_t len, size_t size, const char *str) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
 
voidMEM_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_guarded_printmemlist_pydict (void)
 
void MEM_guarded_printmemlist (void)
 
void MEM_guarded_callbackmemlist (void(*func)(void *))
 
void MEM_guarded_printmemlist_stats (void)
 
void MEM_guarded_set_error_callback (void(*func)(const char *))
 
bool MEM_guarded_consistency_check (void)
 
void MEM_guarded_set_memory_debug (void)
 
size_t MEM_guarded_get_memory_in_use (void)
 
unsigned int MEM_guarded_get_memory_blocks_in_use (void)
 
void MEM_guarded_reset_peak_memory (void)
 
size_t MEM_guarded_get_peak_memory (void) ATTR_WARN_UNUSED_RESULT
 
const char * MEM_guarded_name_ptr (void *vmemh)
 

Variables

bool leak_detector_has_run
 
char free_after_leak_detection_message []
 

Macro Definition Documentation

◆ ALIGNED_MALLOC_MINIMUM_ALIGNMENT

#define ALIGNED_MALLOC_MINIMUM_ALIGNMENT   sizeof(void *)

Definition at line 87 of file mallocn_intern.h.

◆ IS_POW2

#define IS_POW2 (   a)    (((a) & ((a)-1)) == 0)

Definition at line 72 of file mallocn_intern.h.

◆ LIKELY

#define LIKELY (   x)    (x)

Definition at line 51 of file mallocn_intern.h.

◆ MEM_INLINE

#define MEM_INLINE   static inline

Definition at line 69 of file mallocn_intern.h.

◆ MEMHEAD_ALIGN_PADDING

#define MEMHEAD_ALIGN_PADDING (   alignment)     ((size_t)alignment - (sizeof(MemHeadAligned) % (size_t)alignment))

Definition at line 75 of file mallocn_intern.h.

◆ MEMHEAD_REAL_PTR

#define MEMHEAD_REAL_PTR (   memh)    ((char *)memh - MEMHEAD_ALIGN_PADDING(memh->alignment))

Definition at line 79 of file mallocn_intern.h.

◆ SIZET_ALIGN_4

#define SIZET_ALIGN_4 (   len)    ((len + 3) & ~(size_t)3)

Definition at line 45 of file mallocn_intern.h.

◆ SIZET_ARG

#define SIZET_ARG (   a)    ((size_t)(a))

Definition at line 43 of file mallocn_intern.h.

◆ SIZET_FORMAT

#define SIZET_FORMAT   "%zu"

Definition at line 42 of file mallocn_intern.h.

◆ UNLIKELY

#define UNLIKELY (   x)    (x)

Definition at line 52 of file mallocn_intern.h.

◆ UNUSED

#define UNUSED (   x)    UNUSED_##x

Definition at line 14 of file mallocn_intern.h.

◆ USE_MALLOC_USABLE_SIZE

#define USE_MALLOC_USABLE_SIZE   /* internal, when we have malloc_usable_size() */

Definition at line 18 of file mallocn_intern.h.

Function Documentation

◆ aligned_free()

void aligned_free ( void ptr)

Definition at line 76 of file mallocn.c.

References free(), and ptr.

Referenced by MEM_lockfree_freeN(), and rem_memblock().

◆ aligned_malloc()

void* aligned_malloc ( size_t  size,
size_t  alignment 
)

◆ ATTR_NONNULL()

void ATTR_NONNULL ( )

Iterator New.

Takes a bmesh iterator structure and fills it with the appropriate function pointers based upon its type and then calls BMeshIter_step() to return the first element of the iterator.

Given a edge and one of its vertices, returns the other vertex.

Tests whether or not the edge is part of a wire. (ie: has no faces attached to it)

Tests whether or not this edge is manifold. A manifold edge has exactly 2 faces attached to it.

Tests that the edge is manifold and that both its faces point the same way.

Tests whether or not an edge is on the boundary of a shell (has one face associated with it)

Tests whether one loop is next to another within the same face.

Check if we have a single wire edge user.

Definition at line 106 of file MEM_guardedalloc.h.

◆ MEM_guarded_allocN_len()

size_t MEM_guarded_allocN_len ( const void vmemh)

Definition at line 229 of file mallocn_guarded_impl.c.

References MemHead::len.

Referenced by MEM_use_guarded_allocator().

◆ MEM_guarded_callbackmemlist()

void MEM_guarded_callbackmemlist ( void(*)(void *)  func)

◆ MEM_guarded_calloc_arrayN()

void* MEM_guarded_calloc_arrayN ( size_t  len,
size_t  size,
const char *  str 
)

◆ MEM_guarded_callocN()

void* MEM_guarded_callocN ( size_t  len,
const char *  str 
)

◆ MEM_guarded_consistency_check()

bool MEM_guarded_consistency_check ( void  )

Definition at line 206 of file mallocn_guarded_impl.c.

References check_memlist(), localListBase::last, membase, and NULL.

Referenced by MEM_use_guarded_allocator().

◆ MEM_guarded_dupallocN()

void* MEM_guarded_dupallocN ( const void vmemh)

◆ MEM_guarded_freeN()

void MEM_guarded_freeN ( void vmemh)

◆ MEM_guarded_get_memory_blocks_in_use()

unsigned int MEM_guarded_get_memory_blocks_in_use ( void  )

Definition at line 1180 of file mallocn_guarded_impl.c.

References mem_lock_thread(), mem_unlock_thread(), and totblock.

Referenced by MEM_use_guarded_allocator().

◆ MEM_guarded_get_memory_in_use()

size_t MEM_guarded_get_memory_in_use ( void  )

Definition at line 1169 of file mallocn_guarded_impl.c.

References mem_in_use, mem_lock_thread(), and mem_unlock_thread().

Referenced by MEM_use_guarded_allocator().

◆ MEM_guarded_get_peak_memory()

size_t MEM_guarded_get_peak_memory ( void  )

Definition at line 1151 of file mallocn_guarded_impl.c.

References mem_lock_thread(), mem_unlock_thread(), and peak_mem.

Referenced by MEM_use_guarded_allocator().

◆ MEM_guarded_malloc_arrayN()

void* MEM_guarded_malloc_arrayN ( size_t  len,
size_t  size,
const char *  str 
)

◆ MEM_guarded_mallocN()

void* MEM_guarded_mallocN ( size_t  len,
const char *  str 
)

◆ MEM_guarded_mallocN_aligned()

void* MEM_guarded_mallocN_aligned ( size_t  len,
size_t  alignment,
const char *  str 
)

◆ MEM_guarded_name_ptr()

const char* MEM_guarded_name_ptr ( void vmemh)

Definition at line 1192 of file mallocn_guarded_impl.c.

References MemHead::name.

Referenced by MEM_use_guarded_allocator().

◆ MEM_guarded_printmemlist()

void MEM_guarded_printmemlist ( void  )

Definition at line 840 of file mallocn_guarded_impl.c.

References MEM_guarded_printmemlist_internal().

Referenced by MEM_use_guarded_allocator().

◆ MEM_guarded_printmemlist_pydict()

void MEM_guarded_printmemlist_pydict ( void  )

Definition at line 844 of file mallocn_guarded_impl.c.

References MEM_guarded_printmemlist_internal().

Referenced by MEM_use_guarded_allocator().

◆ MEM_guarded_printmemlist_stats()

void MEM_guarded_printmemlist_stats ( void  )

◆ MEM_guarded_reallocN_id()

void* MEM_guarded_reallocN_id ( void vmemh,
size_t  len,
const char *  str 
)

◆ MEM_guarded_recallocN_id()

void* MEM_guarded_recallocN_id ( void vmemh,
size_t  len,
const char *  str 
)

◆ MEM_guarded_reset_peak_memory()

void MEM_guarded_reset_peak_memory ( void  )

◆ MEM_guarded_set_error_callback()

void MEM_guarded_set_error_callback ( void(*)(const char *)  func)

Definition at line 219 of file mallocn_guarded_impl.c.

References error_callback.

Referenced by MEM_use_guarded_allocator().

◆ MEM_guarded_set_memory_debug()

void MEM_guarded_set_memory_debug ( void  )

Definition at line 224 of file mallocn_guarded_impl.c.

References malloc_debug_memset.

Referenced by MEM_use_guarded_allocator().

◆ MEM_lockfree_allocN_len()

size_t MEM_lockfree_allocN_len ( const void vmemh)

◆ MEM_lockfree_callbackmemlist()

void MEM_lockfree_callbackmemlist ( void(*)(void *)  func)

Definition at line 365 of file mallocn_lockfree_impl.c.

References void.

Referenced by MEM_use_lockfree_allocator().

◆ MEM_lockfree_calloc_arrayN()

void* MEM_lockfree_calloc_arrayN ( size_t  len,
size_t  size,
const char *  str 
)

◆ MEM_lockfree_callocN()

void* MEM_lockfree_callocN ( size_t  len,
const char *  str 
)

◆ MEM_lockfree_consistency_check()

bool MEM_lockfree_consistency_check ( void  )

Definition at line 389 of file mallocn_lockfree_impl.c.

Referenced by MEM_use_lockfree_allocator().

◆ MEM_lockfree_dupallocN()

void* MEM_lockfree_dupallocN ( const void vmemh)

◆ MEM_lockfree_freeN()

void MEM_lockfree_freeN ( void vmemh)

◆ MEM_lockfree_get_memory_blocks_in_use()

unsigned int MEM_lockfree_get_memory_blocks_in_use ( void  )

Definition at line 404 of file mallocn_lockfree_impl.c.

References totblock.

Referenced by MEM_use_lockfree_allocator().

◆ MEM_lockfree_get_memory_in_use()

size_t MEM_lockfree_get_memory_in_use ( void  )

Definition at line 399 of file mallocn_lockfree_impl.c.

References mem_in_use.

Referenced by MEM_use_lockfree_allocator().

◆ MEM_lockfree_get_peak_memory()

size_t MEM_lockfree_get_peak_memory ( void  )

Definition at line 415 of file mallocn_lockfree_impl.c.

References peak_mem.

Referenced by MEM_use_lockfree_allocator().

◆ MEM_lockfree_malloc_arrayN()

void* MEM_lockfree_malloc_arrayN ( size_t  len,
size_t  size,
const char *  str 
)

◆ MEM_lockfree_mallocN()

void* MEM_lockfree_mallocN ( size_t  len,
const char *  str 
)

◆ MEM_lockfree_mallocN_aligned()

void* MEM_lockfree_mallocN_aligned ( size_t  len,
size_t  alignment,
const char *  str 
)

◆ MEM_lockfree_name_ptr()

const char* MEM_lockfree_name_ptr ( void vmemh)

Definition at line 421 of file mallocn_lockfree_impl.c.

Referenced by MEM_use_lockfree_allocator().

◆ MEM_lockfree_printmemlist()

void MEM_lockfree_printmemlist ( void  )

Definition at line 360 of file mallocn_lockfree_impl.c.

Referenced by MEM_use_lockfree_allocator().

◆ MEM_lockfree_printmemlist_pydict()

void MEM_lockfree_printmemlist_pydict ( void  )

Definition at line 356 of file mallocn_lockfree_impl.c.

Referenced by MEM_use_lockfree_allocator().

◆ MEM_lockfree_printmemlist_stats()

void MEM_lockfree_printmemlist_stats ( void  )

Definition at line 370 of file mallocn_lockfree_impl.c.

References mem_in_use, and peak_mem.

Referenced by MEM_use_lockfree_allocator().

◆ MEM_lockfree_reallocN_id()

void* MEM_lockfree_reallocN_id ( void vmemh,
size_t  len,
const char *  str 
)

◆ MEM_lockfree_recallocN_id()

void* MEM_lockfree_recallocN_id ( void vmemh,
size_t  len,
const char *  str 
)

◆ MEM_lockfree_reset_peak_memory()

void MEM_lockfree_reset_peak_memory ( void  )

Definition at line 410 of file mallocn_lockfree_impl.c.

References mem_in_use, and peak_mem.

Referenced by MEM_use_lockfree_allocator().

◆ MEM_lockfree_set_error_callback()

void MEM_lockfree_set_error_callback ( void(*)(const char *)  func)

Definition at line 384 of file mallocn_lockfree_impl.c.

References error_callback.

Referenced by MEM_use_lockfree_allocator().

◆ MEM_lockfree_set_memory_debug()

void MEM_lockfree_set_memory_debug ( void  )

Definition at line 394 of file mallocn_lockfree_impl.c.

References malloc_debug_memset.

Referenced by MEM_use_lockfree_allocator().

Variable Documentation

◆ free_after_leak_detection_message

char free_after_leak_detection_message[]
extern

Definition at line 14 of file leak_detector.cc.

Referenced by MEM_guarded_freeN(), and MEM_lockfree_freeN().

◆ leak_detector_has_run

bool leak_detector_has_run
extern

Definition at line 13 of file leak_detector.cc.

Referenced by MEM_guarded_freeN(), and MEM_lockfree_freeN().