Commit: 8d6215f453e9a5b420743dfa44165d474feea45e
Parent: 56cfd92930f9e8a5da3e5cf6fa372d5b7ba326e7
Author: Randy Palamar
Date: Sun, 18 Jan 2026 12:27:02 -0700
util: make temp_arena save whole arena
Since there are now helpers allocating off the end of the Arena we
need to also restore the end pointer
Diffstat:
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/util.c b/util.c
@@ -190,7 +190,7 @@ sub_arena_end(Arena *a, iz len, uz align)
function TempArena
begin_temp_arena(Arena *a)
{
- TempArena result = {.arena = a, .old_beg = a->beg};
+ TempArena result = {.arena = a, .original_arena = *a};
return result;
}
@@ -199,8 +199,8 @@ end_temp_arena(TempArena ta)
{
Arena *a = ta.arena;
if (a) {
- assert(a->beg >= ta.old_beg);
- a->beg = ta.old_beg;
+ assert(a->beg >= ta.original_arena.beg);
+ *a = ta.original_arena;
}
}
diff --git a/util.h b/util.h
@@ -192,7 +192,7 @@ typedef alignas(16) union {
} u128;
typedef struct { u8 *beg, *end; } Arena;
-typedef struct { Arena *arena; u8 *old_beg; } TempArena;
+typedef struct { Arena *arena, original_arena; } TempArena;
typedef struct { iz len; u8 *data; } s8;
#define s8(s) (s8){.len = countof(s) - 1, .data = (u8 *)s}