Skip to content

Saumya40-codes/bump-allocator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

bump allocator

A minimal bump allocator in C demonstrating memory alignment and arena-style allocation.

what it shows

  • why alignment matters (x86 slows down, ARM crashes on misaligned access)
  • how sbrk/brk work to grow and reset the heap
  • internal fragmentation from padding to alignment boundaries
  • arena reset — free everything at once by rewinding the heap pointer

build & run

make
make run

note

after allocator_reset(), any previously allocated pointers (a, b) are dangling, accessing them is undefined behavior. this is the tradeoff of arena allocation.

related

blog post: Why raw pointers can betray you

Releases

No releases published

Packages

 
 
 

Contributors