MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / _mi_heap_malloc_zero_ex

Function _mi_heap_malloc_zero_ex

3rd/mimalloc-2.0.9/src/alloc.c:127–146  ·  view source on GitHub ↗

The main allocation function

Source from the content-addressed store, hash-verified

125
126// The main allocation function
127extern inline void* _mi_heap_malloc_zero_ex(mi_heap_t* heap, size_t size, bool zero, size_t huge_alignment) mi_attr_noexcept {
128 if mi_likely(size <= MI_SMALL_SIZE_MAX) {
129 mi_assert_internal(huge_alignment == 0);
130 return mi_heap_malloc_small_zero(heap, size, zero);
131 }
132 else {
133 mi_assert(heap!=NULL);
134 mi_assert(heap->thread_id == 0 || heap->thread_id == _mi_thread_id()); // heaps are thread local
135 void* const p = _mi_malloc_generic(heap, size + MI_PADDING_SIZE, zero, huge_alignment); // note: size can overflow but it is detected in malloc_generic
136 mi_assert_internal(p == NULL || mi_usable_size(p) >= size);
137 #if MI_STAT>1
138 if (p != NULL) {
139 if (!mi_heap_is_initialized(heap)) { heap = mi_get_default_heap(); }
140 mi_heap_stat_increase(heap, malloc, mi_usable_size(p));
141 }
142 #endif
143 mi_track_malloc(p,size,zero);
144 return p;
145 }
146}
147
148extern inline void* _mi_heap_malloc_zero(mi_heap_t* heap, size_t size, bool zero) mi_attr_noexcept {
149 return _mi_heap_malloc_zero_ex(heap, size, zero, 0);

Callers 2

_mi_heap_malloc_zeroFunction · 0.85

Calls 6

_mi_thread_idFunction · 0.85
_mi_malloc_genericFunction · 0.85
mi_usable_sizeFunction · 0.85
mi_heap_is_initializedFunction · 0.85
mi_get_default_heapFunction · 0.85

Tested by

no test coverage detected