Fast allocation in a page: just pop from the free list. Fall back to generic allocation only if the list is empty.
| 27 | // Fast allocation in a page: just pop from the free list. |
| 28 | // Fall back to generic allocation only if the list is empty. |
| 29 | extern inline void* _mi_page_malloc(mi_heap_t* heap, mi_page_t* page, size_t size, bool zero) mi_attr_noexcept { |
| 30 | mi_assert_internal(page->xblock_size==0||mi_page_block_size(page) >= size); |
| 31 | mi_block_t* const block = page->free; |
| 32 | if mi_unlikely(block == NULL) { |
| 33 | return _mi_malloc_generic(heap, size, zero, 0); |
| 34 | } |
| 35 | mi_assert_internal(block != NULL && _mi_ptr_page(block) == page); |
| 36 | // pop from the free list |
| 37 | page->used++; |
no test coverage detected