| 554 | } |
| 555 | |
| 556 | static mi_decl_noinline void mi_page_free_list_extend( mi_page_t* const page, const size_t bsize, const size_t extend, mi_stats_t* const stats) |
| 557 | { |
| 558 | MI_UNUSED(stats); |
| 559 | #if (MI_SECURE <= 2) |
| 560 | mi_assert_internal(page->free == NULL); |
| 561 | mi_assert_internal(page->local_free == NULL); |
| 562 | #endif |
| 563 | mi_assert_internal(page->capacity + extend <= page->reserved); |
| 564 | mi_assert_internal(bsize == mi_page_block_size(page)); |
| 565 | void* const page_area = _mi_page_start(_mi_page_segment(page), page, NULL ); |
| 566 | |
| 567 | mi_block_t* const start = mi_page_block_at(page, page_area, bsize, page->capacity); |
| 568 | |
| 569 | // initialize a sequential free list |
| 570 | mi_block_t* const last = mi_page_block_at(page, page_area, bsize, page->capacity + extend - 1); |
| 571 | mi_block_t* block = start; |
| 572 | while(block <= last) { |
| 573 | mi_block_t* next = (mi_block_t*)((uint8_t*)block + bsize); |
| 574 | mi_block_set_next(page,block,next); |
| 575 | block = next; |
| 576 | } |
| 577 | // prepend to free list (usually `NULL`) |
| 578 | mi_block_set_next(page, last, page->free); |
| 579 | page->free = start; |
| 580 | } |
| 581 | |
| 582 | /* ----------------------------------------------------------- |
| 583 | Page initialize and extend the capacity |
no test coverage detected