diff options
Diffstat (limited to 'src/std/mem.c')
-rw-r--r-- | src/std/mem.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/std/mem.c b/src/std/mem.c index f5b92d4..5468898 100644 --- a/src/std/mem.c +++ b/src/std/mem.c @@ -11,12 +11,12 @@ void* arena_alloc_align(arena* a, size_t size, size_t align) { ptrdiff_t padding = -(uintptr_t)a->curr & (align - 1); ptrdiff_t available = a->end - a->curr - padding; - TRACE("Padding %td available %td", padding, available); + // TRACE("Padding %td available %td", padding, available); if (available < 0 || (ptrdiff_t)size > available) { ERROR_EXIT("Arena ran out of memory\n"); } - void* p = a->begin + padding; - a->begin += padding + size; + void* p = a->curr + padding; + a->curr += padding + size; return memset(p, 0, size); } void* arena_alloc(arena* a, size_t size) { return arena_alloc_align(a, size, DEFAULT_ALIGNMENT); } @@ -29,4 +29,6 @@ arena arena_create(void* backing_buffer, size_t capacity) { void arena_free_all(arena* a) { a->curr = a->begin; // pop everything at once and reset to the start. -}
\ No newline at end of file +} + +void arena_free_storage(arena* a) { free(a->begin); }
\ No newline at end of file |