From bdead26c7743764f8e49d5a0a7e3e87dac1580fc Mon Sep 17 00:00:00 2001 From: daanx Date: Sat, 22 Apr 2023 17:26:51 -0700 Subject: [PATCH] improve static alloc precision --- src/arena.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arena.c b/src/arena.c index 04d5c49c..9ae78469 100644 --- a/src/arena.c +++ b/src/arena.c @@ -146,7 +146,7 @@ static _Atomic(size_t) mi_arena_static_top; static void* mi_arena_static_zalloc(size_t size, size_t alignment, mi_memid_t* memid) { *memid = _mi_memid_none(); if (size == 0 || size > MI_ARENA_STATIC_MAX) return NULL; - if (mi_atomic_load_relaxed(&mi_arena_static_top) >= MI_ARENA_STATIC_MAX) return NULL; + if ((mi_atomic_load_relaxed(&mi_arena_static_top) + size) > MI_ARENA_STATIC_MAX) return NULL; // try to claim space if (alignment == 0) { alignment = 1; }