Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arena Allocator (C)

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.

Project Goals

  • 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

Structure

  • include/arena.h: public API and types
  • src/arena.c: allocator implementation
  • src/main.c: small demo program
  • Makefile: build and run helpers

Build

make

Run

make run

Clean

make clean

API Overview

  • Arena *ArenaAlloc(U64 capacity): create arena with capacity in U64 elements
  • void ArenaRelease(Arena *arena): free arena memory
  • U64 ArenaPos(const Arena *arena): current write position
  • void ArenaClear(Arena *arena): reset arena to empty state
  • void *ArenaPushNoZero(Arena *arena, U64 size): allocate payload without zeroing
  • void *ArenaPush(Arena *arena, U64 size): allocate payload and zero memory
  • void *ArenaPop(Arena *arena): pop most recent allocation (LIFO)
  • bool IsFull(const Arena *arena): true when arena is full

Notes

  • Capacity and allocation sizes are measured in U64 elements (not bytes).
  • ArenaPop returns NULL when there is nothing left to pop.

Next Improvements

  • Add unit tests for edge cases and overflow behavior
  • Add CI workflow for build checks

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages