From 9427c3d324c63f8f2e3b42e616352ce2f6e2edfd Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Fri, 1 Nov 2024 08:15:46 +0000 Subject: Implement arena_reset --- arena.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'arena.h') 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); -- cgit v1.2.3-13-gbd6f