From: Brendan Hansen Date: Fri, 15 May 2020 19:50:26 +0000 (-0500) Subject: Small bug / performance fix X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=cc3675833771831c55c59ff295050fff0fea44d5;p=onyx.git Small bug / performance fix --- diff --git a/bh.h b/bh.h index 1febb5f1..78e91d5e 100644 --- a/bh.h +++ b/bh.h @@ -658,17 +658,18 @@ BH_ALLOCATOR_PROC(bh_alloc_nofree_allocator_proc) { switch (action) { case bh_allocator_action_alloc: { - size = bh__align(size, alignment); - retval = alloc_nf->next_allocation; + size = bh__align(size, alignment); alloc_nf->next_allocation = bh_pointer_add(alloc_nf->next_allocation, size); - alloc_nf->size += size; - if (alloc_nf->size > alloc_nf->total_size) { + + if (alloc_nf->size + size >= alloc_nf->total_size) { // Out of memory fprintf(stderr, "NoFree allocator out of memory\n"); return NULL; } + + alloc_nf->size += size; } break; case bh_allocator_action_resize: { diff --git a/onyx b/onyx index 7191babc..b8911011 100755 Binary files a/onyx and b/onyx differ