memory/arena: fix alignment offset calculation

Previously would add an unnecessary padding equal to alignment if the
pointer is already sufficiently aligned
This commit is contained in:
Andrei Alexeyev 2024-09-05 16:41:02 +02:00
parent 1ca51a6690
commit 1fc752531a
No known key found for this signature in database
GPG key ID: 72D26128040B9690

View file

@ -54,7 +54,7 @@ static void *_arena_alloc(MemArena *arena, size_t size, size_t align) {
for(;;) {
auto available = page->size - page_ofs;
alignofs = align - ((uintptr_t)(page->data + page_ofs) & (align - 1));
alignofs = (align - (uintptr_t)(page->data + page_ofs)) & (align - 1);
required = alignofs + size;
if(available < required) {