better fast path for aligned allocation; check max alloc size correctly in the aligned fallback

This commit is contained in:
Daan 2024-05-10 20:19:17 -07:00
parent 605c354bd4
commit c70c1df16a
2 changed files with 33 additions and 17 deletions

View file

@ -230,6 +230,23 @@ int main(void) {
result = (((uintptr_t)p % 0x100) == 0); // #602
mi_free(p);
}
CHECK_BODY("mimalloc-aligned13") {
bool ok = true;
for( size_t size = 1; size <= MI_SMALL_SIZE_MAX && ok; size++ ) {
for(size_t align = 1; align <= size && ok; align *= 2 ) {
void* p = mi_malloc_aligned(size,align);
ok = (p != NULL && ((uintptr_t)p % align) == 0);
mi_free(p);
/*
if (ok && align <= size && ((size + MI_PADDING_SIZE) & (align-1)) == 0) {
size_t bsize = mi_good_size(size);
ok = (align <= bsize && ((bsize + MI_PADDING_SIZE) & (align-1)) == 0);
}
*/
}
}
result = ok;
}
CHECK_BODY("malloc-aligned-at1") {
void* p = mi_malloc_aligned_at(48,32,0); result = (p != NULL && ((uintptr_t)(p) + 0) % 32 == 0); mi_free(p);
};