mimalloc icon indicating copy to clipboard operation
mimalloc copied to clipboard

Question about the return value of method `mi_page_extend_free(...)`

Open laosijikaichele opened this issue 4 months ago • 1 comments

Does the following code should return false instead of true?

https://github.com/microsoft/mimalloc/blob/09a27098aa6e9286518bd9c74e6ffa7199c3f04e/src/page.c#L642

Which should signal the page extend failed?

laosijikaichele avatar Aug 02 '25 10:08 laosijikaichele

From looking at the usage it seems more consistent if the capacity >= reserved case returned false as you suggested. Callers appear to interpret false as "extend failed" and true as "blocks available".

The code above also caught my eye:

mi_assert(page->free == NULL);
if (page->free != NULL) return true;

In debug it aborts, in release it silently “succeeds”. Might be worth aligning that so both builds handle it the same way..?

johnou avatar Aug 06 '25 01:08 johnou