From 51b4a3fc75351d6ecd2142c228d31a1f7ed52152 Mon Sep 17 00:00:00 2001 From: Omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Sun, 17 Mar 2024 15:00:53 +1100 Subject: fix a bug with dirname seg faulting when passed a string literal it doesnt like things in readonly memory i guess. now we create an arena for the obj load and create a dynamically allocated copy of the string --- src/std/mem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/std/mem.c') diff --git a/src/std/mem.c b/src/std/mem.c index f5b92d4..d7c0f4c 100644 --- a/src/std/mem.c +++ b/src/std/mem.c @@ -16,7 +16,7 @@ void* arena_alloc_align(arena* a, size_t size, size_t align) { ERROR_EXIT("Arena ran out of memory\n"); } void* p = a->begin + padding; - a->begin += padding + size; + 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 -- cgit v1.2.3-70-g09d2