A small stack-style arena allocator written in C for learning and portfolio use. It supports fast linear allocation with LIFO pop semantics by storing a tiny header before each payload.
- Implement a minimal custom allocator in plain C
- Practice low-level memory layout and pointer arithmetic
- Provide a clean, readable codebase suitable for a portfolio
include/arena.h: public API and typessrc/arena.c: allocator implementationsrc/main.c: small demo programMakefile: build and run helpers
makemake runmake cleanArena *ArenaAlloc(U64 capacity): create arena with capacity inU64elementsvoid ArenaRelease(Arena *arena): free arena memoryU64 ArenaPos(const Arena *arena): current write positionvoid ArenaClear(Arena *arena): reset arena to empty statevoid *ArenaPushNoZero(Arena *arena, U64 size): allocate payload without zeroingvoid *ArenaPush(Arena *arena, U64 size): allocate payload and zero memoryvoid *ArenaPop(Arena *arena): pop most recent allocation (LIFO)bool IsFull(const Arena *arena): true when arena is full
- Capacity and allocation sizes are measured in
U64elements (not bytes). ArenaPopreturnsNULLwhen there is nothing left to pop.
- Add unit tests for edge cases and overflow behavior
- Add CI workflow for build checks