Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arena bytes alloced #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down