Scratch arena, in-place temporary gebs_fmt() macro

This commit is contained in:
kamkow1
2025-05-19 14:09:07 +02:00
parent c905379d14
commit dbe1af7125
3 changed files with 207 additions and 13 deletions

26
example/arena.c Normal file
View File

@ -0,0 +1,26 @@
#define GEBS_IMPLEMENTATION
#include "../gebs.h"
typedef struct {
int *items;
size_t count, capacity;
} Ints;
int main(void)
{
Gebs_Arena *arena = gebs_arena_make(1024);
defer { gebs_arena_destroy(arena); }
Ints ints = {0};
defer { gebs_list_free_alloc(arena, &ints); }
for (size_t i = 0; i < 1000; i++) {
gebs_list_append_alloc(arena, &ints, i);
}
for (size_t i = 0; i < ints.count; i++) {
printf("%zu\n", i);
}
printf("%s\n", gebs_fmt("Hello formatting %d", 124));
return 0;
}