ArenaAllocators don't play nicely with ArrayLists(openmymind.net) |
ArenaAllocators don't play nicely with ArrayLists(openmymind.net) |
char *dat = malloc(42);
arena_push_dtor(ar, dat, free);
// use dat
Neatly solves the problem of stuff that's too awkward to put in linear memory while still letting you be lazy about cleanup.Also: if you don't need the contiguity you can simply break up your dynamic array into linked buckets the same way the arena internally does with its own memory. Iteration and random access will still be fast.
https://ziglang.org/documentation/0.16.0/std/#std.heap.Arena...