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

Function mi_page_free_list_extend

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

Source from the content-addressed store, hash-verified

554}
555
556static 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

Callers 1

mi_page_extend_freeFunction · 0.85

Calls 5

mi_page_block_sizeFunction · 0.85
_mi_page_startFunction · 0.85
_mi_page_segmentFunction · 0.85
mi_page_block_atFunction · 0.85
mi_block_set_nextFunction · 0.85

Tested by

no test coverage detected