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

Function mi_heap_malloc_small_zero

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

Source from the content-addressed store, hash-verified

90}
91
92static inline mi_decl_restrict void* mi_heap_malloc_small_zero(mi_heap_t* heap, size_t size, bool zero) mi_attr_noexcept {
93 mi_assert(heap != NULL);
94 #if MI_DEBUG
95 const uintptr_t tid = _mi_thread_id();
96 mi_assert(heap->thread_id == 0 || heap->thread_id == tid); // heaps are thread local
97 #endif
98 mi_assert(size <= MI_SMALL_SIZE_MAX);
99#if (MI_PADDING)
100 if (size == 0) {
101 size = sizeof(void*);
102 }
103#endif
104 mi_page_t* page = _mi_heap_get_free_small_page(heap, size + MI_PADDING_SIZE);
105 void* p = _mi_page_malloc(heap, page, size + MI_PADDING_SIZE, zero);
106 mi_assert_internal(p == NULL || mi_usable_size(p) >= size);
107#if MI_STAT>1
108 if (p != NULL) {
109 if (!mi_heap_is_initialized(heap)) { heap = mi_get_default_heap(); }
110 mi_heap_stat_increase(heap, malloc, mi_usable_size(p));
111 }
112#endif
113 mi_track_malloc(p,size,zero);
114 return p;
115}
116
117// allocate a small block
118mi_decl_nodiscard extern inline mi_decl_restrict void* mi_heap_malloc_small(mi_heap_t* heap, size_t size) mi_attr_noexcept {

Callers 3

mi_heap_malloc_smallFunction · 0.85
_mi_heap_malloc_zero_exFunction · 0.85
mi_zalloc_smallFunction · 0.85

Calls 6

_mi_thread_idFunction · 0.85
_mi_page_mallocFunction · 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