summaryrefslogtreecommitdiff
path: root/src/std
diff options
context:
space:
mode:
authorJoshua Rowe <17525998+omnisci3nce@users.noreply.github.com>2024-04-20 18:33:05 +1000
committerGitHub <noreply@github.com>2024-04-20 18:33:05 +1000
commitb283835c5e6998bda9b986ff49ee4fd57fe68fc7 (patch)
treebe478c168506a669876ff9df8920b7e35539e98f /src/std
parentb240374c23365e33727d78ca74e901bcb383e077 (diff)
parent013e1c111e0717f6dc01a8e8582e13a4095e05bc (diff)
Merge pull request #7 from omnisci3nce/transform-hierarchy
Transform hierarchy
Diffstat (limited to 'src/std')
-rw-r--r--src/std/mem.c6
-rw-r--r--src/std/mem.h1
2 files changed, 5 insertions, 2 deletions
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
diff --git a/src/std/mem.h b/src/std/mem.h
index c3ec61d..2f92894 100644
--- a/src/std/mem.h
+++ b/src/std/mem.h
@@ -22,4 +22,5 @@ arena arena_create(void* backing_buffer, size_t capacity);
void* arena_alloc(arena* a, size_t size);
void* arena_alloc_align(arena* a, size_t size, size_t align);
void arena_free_all(arena* a);
+void arena_free_storage(arena* a);
// TODO: arena_resize \ No newline at end of file