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

Function _mi_malloc_generic

3rd/mimalloc-2.0.9/src/page.c:881–889  ·  view source on GitHub ↗

Generic allocation routine if the fast path (`alloc.c:mi_page_malloc`) does not succeed. Note: in debug mode the size includes MI_PADDING_SIZE and might have overflowed. The `huge_alignment` is normally 0 but is set to a multiple of MI_SEGMENT_SIZE for very large requested alignments in which case we use a huge segment.

Source from the content-addressed store, hash-verified

879// The `huge_alignment` is normally 0 but is set to a multiple of MI_SEGMENT_SIZE for
880// very large requested alignments in which case we use a huge segment.
881void* _mi_malloc_generic(mi_heap_t* heap, size_t size, bool zero, size_t huge_alignment) mi_attr_noexcept
882{
883 mi_assert_internal(heap != NULL);
884
885 // initialize if necessary
886 if mi_unlikely(!mi_heap_is_initialized(heap)) {
887 mi_thread_init(); // calls `_mi_heap_init` in turn
888 heap = mi_get_default_heap();
889 if mi_unlikely(!mi_heap_is_initialized(heap)) { return NULL; }
890 }
891 mi_assert_internal(mi_heap_is_initialized(heap));
892

Callers 2

_mi_page_mallocFunction · 0.85
_mi_heap_malloc_zero_exFunction · 0.85

Calls 4

mi_unlikelyFunction · 0.85
mi_heap_is_initializedFunction · 0.85
mi_thread_initFunction · 0.85
mi_get_default_heapFunction · 0.85

Tested by

no test coverage detected