
Write a two-function allocator over a 4096-byte static pool: heap_alloc hands out 8-aligned blocks from a free list, heap_free gives one back and merges it with a free neighbour.
p = heap_alloc(32); heap_free(p);Expected result
alloc:ok
align:ok overlap:none inpool:okFor your own tracking. Tests grade your code.
sixteen times heap_alloc(24)Expected result
split:ok
align:ok overlap:none inpool:okfill the pool with heap_alloc(256), free two neighbours, heap_alloc(400)Expected result
coalesce:ok
align:ok overlap:none inpool:okheap_alloc(0) then heap_alloc(64)Expected result
null
alloc:ok
align:ok overlap:none inpool:okheap_alloc(SIZE_MAX), heap_alloc(SIZE_MAX - 8), heap_alloc(64)Expected result
null
null
alloc:ok
align:ok overlap:none inpool:okExpected files
heap_alloc.cAllowed functions
None. Write every helper yourself.
Allowed headers

v0.40: Create exercises. Challenge the community.
Meet Studio →Write a two-function allocator over a 4096-byte static pool: heap_alloc hands out 8-aligned blocks from a free list, heap_free gives one back and merges it with a free neighbour.
p = heap_alloc(32); heap_free(p);Expected result
alloc:ok
align:ok overlap:none inpool:okFor your own tracking. Tests grade your code.
sixteen times heap_alloc(24)Expected result
split:ok
align:ok overlap:none inpool:okfill the pool with heap_alloc(256), free two neighbours, heap_alloc(400)Expected result
coalesce:ok
align:ok overlap:none inpool:okheap_alloc(0) then heap_alloc(64)Expected result
null
alloc:ok
align:ok overlap:none inpool:okheap_alloc(SIZE_MAX), heap_alloc(SIZE_MAX - 8), heap_alloc(64)Expected result
null
null
alloc:ok
align:ok overlap:none inpool:okExpected files
heap_alloc.cAllowed functions
None. Write every helper yourself.
Allowed headers

Run the tests to grade your code
Build your code, then check each test here. Open a result to inspect its output.