Scratch arena, in-place temporary gebs_fmt() macro
This commit is contained in:
26
example/arena.c
Normal file
26
example/arena.c
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user