From f537673ea22e4f127a5afdd276f646e992a618c3 Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Tue, 1 Feb 2022 12:39:34 -0500 Subject: [PATCH] track arena free size when allocating blocks --- src/util.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util.h b/src/util.h index 205e572..9581f9b 100644 --- a/src/util.h +++ b/src/util.h @@ -25,6 +25,7 @@ u64 utilFNV64a_str(const char* str, u64 hval = FNV1_64_INIT); struct MemoryArena { size_t max_size; + size_t free_size; void* head; void* next_free; }; @@ -117,6 +118,7 @@ arenaAllocateBlock(MemoryArena* arena, size_t block_size) assert(block_size > 0); void* ret = arena->next_free; arena->next_free = (uint8_t*) arena->next_free + block_size; + arena->free_size = arenaGetFreeSize(arena); return ret; }