Master the fundamental concepts of c programming deep dive through this focused micro-challenge.
Arena allocators (region allocators) grab one big block and hand out slices by advancing an offset. Apache's apr_pool, protobuf arenas in Google services, and LLVM's AST allocation all use this pattern: allocate thousands of small objects, free everything in one reset or at scope end.
cLoading…
No per-object free, no fragmentation walks, cache-friendly contiguous layout.
You cannot reclaim one string in the middle of a frame without resetting the whole arena. Memory stays reserved until arena_free. That is acceptable when lifetimes are tied to a request, a compiler pass, or a game tick.
For this exercise, you will implement arena_create, arena_alloc, arena_reset, and arena_free on a 1024-byte buffer. This task asks you to measure bytes consumed via offset, because choosing arena vs malloc per object is one of the highest-impact architecture calls in systems C.
Keep the relevant man page, ABI doc, or Rust reference chapter open while you work. When your output disagrees with the reference implementation on the same machine, the mismatch is usually an alignment rule, an off-by-one terminator, or a register slot you misread in GDB.
Implement an arena allocator for fast memory allocation and bulk deallocation.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github