summaryrefslogtreecommitdiff
path: root/arena.h
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-11-01 08:15:46 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-11-01 08:15:46 +0000
commit9427c3d324c63f8f2e3b42e616352ce2f6e2edfd (patch)
treea9d5b585584400fd7634fc2f58b6a78d7e9648d1 /arena.h
parentcf93eede6bbe790c8eda220fd2ac65a68941d687 (diff)
downloadprick-9427c3d324c63f8f2e3b42e616352ce2f6e2edfd.tar.gz
prick-9427c3d324c63f8f2e3b42e616352ce2f6e2edfd.tar.bz2
prick-9427c3d324c63f8f2e3b42e616352ce2f6e2edfd.zip
Implement arena_reset
Diffstat (limited to 'arena.h')
-rw-r--r--arena.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/arena.h b/arena.h
index 319384c..9432ff4 100644
--- a/arena.h
+++ b/arena.h
@@ -157,6 +157,15 @@ uint8_t *arena_realloc(arena_t *arena, uint8_t *pointer, uint32_t old_size,
return new_ptr;
}
+void arena_reset(arena_t *arena)
+{
+ for (region_t *region = arena->beg; region; region = region->next)
+ {
+ region->size = 0;
+ memset(region->bytes, 0, region->capacity);
+ }
+}
+
void arena_free(arena_t *arena)
{
region_delete_rec(arena->beg);