
Write heap_alloc and heap_free, an allocator over one 4096-byte static pool in which freed neighbouring blocks become one block again.
p = heap_alloc(32); heap_free(p);alloc:ok
align:ok overlap:none inpool:okfill the pool with heap_alloc(256), free two neighbours, heap_alloc(400)coalesce:ok
align:ok overlap:none inpool:okheap_alloc(0) then heap_alloc(64)null
alloc:ok
align:ok overlap:none inpool:okheap_alloc(SIZE_MAX), heap_alloc(SIZE_MAX - 8), heap_alloc(64)null
null
alloc:ok
align:ok overlap:none inpool:okheap_alloc.c<stddef.h>defines size_t
Run the tests to grade your code
Write heap_alloc and heap_free, an allocator over one 4096-byte static pool in which freed neighbouring blocks become one block again.
p = heap_alloc(32); heap_free(p);alloc:ok
align:ok overlap:none inpool:okfill the pool with heap_alloc(256), free two neighbours, heap_alloc(400)coalesce:ok
align:ok overlap:none inpool:okheap_alloc(0) then heap_alloc(64)null
alloc:ok
align:ok overlap:none inpool:okheap_alloc(SIZE_MAX), heap_alloc(SIZE_MAX - 8), heap_alloc(64)null
null
alloc:ok
align:ok overlap:none inpool:okheap_alloc.c<stddef.h>defines size_t
Run the tests to grade your code
Memory will appear here