diff --git a/arena.h b/arena.h index 410bae6..82f35ad 100644 --- a/arena.h +++ b/arena.h @@ -75,6 +75,7 @@ void *arena_memdup(Arena *a, void *data, size_t size); char *arena_sprintf(Arena *a, const char *format, ...); #endif // ARENA_NOSTDIO +size_t arena_bytes(Arena *a); void arena_reset(Arena *a); void arena_free(Arena *a); @@ -278,6 +279,14 @@ char *arena_sprintf(Arena *a, const char *format, ...) } #endif // ARENA_NOSTDIO +size_t arena_bytes(Arena *a) { + size_t bytes_total = 0; + for (Region* r = a->begin; r != NULL; r = r->next) { + bytes_total += r->count * sizeof(uintptr_t); + } + return bytes_total; +} + void arena_reset(Arena *a) { for (Region *r = a->begin; r != NULL; r = r->next) {