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.
| 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. |
| 881 | void* _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 |
no test coverage detected