| 90 | } |
| 91 | |
| 92 | static 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 |
| 118 | mi_decl_nodiscard extern inline mi_decl_restrict void* mi_heap_malloc_small(mi_heap_t* heap, size_t size) mi_attr_noexcept { |
no test coverage detected