From f788e3c9a3481d425cea81b037d20107541a087f Mon Sep 17 00:00:00 2001 From: daan Date: Sun, 6 Nov 2022 14:18:52 -0800 Subject: [PATCH] add comment --- src/page.c | 6 ++++-- src/segment.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/page.c b/src/page.c index 48ee1f56..414438b4 100644 --- a/src/page.c +++ b/src/page.c @@ -260,11 +260,13 @@ static mi_page_t* mi_page_fresh_alloc(mi_heap_t* heap, mi_page_queue_t* pq, size // this may be out-of-memory, or an abandoned page was reclaimed (and in our queue) return NULL; } - // a fresh page was found, initialize it mi_assert_internal(pq==NULL || _mi_page_segment(page)->page_kind != MI_PAGE_HUGE); mi_assert_internal(pq!=NULL || page->xblock_size != 0); mi_assert_internal(pq!=NULL || mi_page_block_size(page) >= block_size); - mi_page_init(heap, page, (pq==NULL ? mi_page_block_size(page) : block_size), heap->tld); + // a fresh page was found, initialize it + const size_t full_block_size = (pq == NULL ? mi_page_block_size(page) : block_size); // see also: mi_segment_huge_page_alloc + mi_assert_internal(full_block_size >= block_size); + mi_page_init(heap, page, full_block_size, heap->tld); mi_heap_stat_increase(heap, pages, 1); if (pq!=NULL) mi_page_queue_push(heap, pq, page); // huge pages use pq==NULL mi_assert_expensive(_mi_page_is_valid(page)); diff --git a/src/segment.c b/src/segment.c index 12c9e108..7f80bf8f 100644 --- a/src/segment.c +++ b/src/segment.c @@ -1273,7 +1273,7 @@ static mi_page_t* mi_segment_huge_page_alloc(size_t size, size_t page_alignment, // overallocate to accommodate large alignments. size_t psize; _mi_segment_page_start(segment, page, 0, &psize, NULL); - page->xblock_size = (psize > MI_HUGE_BLOCK_SIZE ? MI_HUGE_BLOCK_SIZE : psize); + page->xblock_size = (psize > MI_HUGE_BLOCK_SIZE ? MI_HUGE_BLOCK_SIZE : (uint32_t)psize); return page; }