The finale runs a full allocate, write, free, calloc, realloc-free workload against the allocator and asserts the exact final heap - fully coalesced, uncorrupted, with nothing leaked. Every layer you built proves itself at once.
Run a scripted workload and assert the exact final layout, a clean checker, and no leaks.
This is the promise the whole project was built to keep: a real memory
allocator. The script exercises every piece at once - Malloc carves three blocks
from the arena with splitting, a write proves the payload is usable, Free and
Calloc show a freed block reused and scrubbed clean, and the final three frees
walk the heap back through backward coalescing until it is one whole free block
again. The exact final Dump of 0:128:F is only reachable if splitting,
coalescing, and binning all agree.
Then the two self-checks close the loop: Check confirms the blocks tile the arena
with matching tags and no adjacent free pairs, and Stats confirms every allocation
came back - AllocBlocks is 0 and all 128 bytes are free. From a bump allocator that
could only free everything at once, you have built the honest core of a real
allocator - boundary-tagged blocks, an explicit segregated free list, first-fit and
best-fit placement, realloc and calloc, coalescing, and a heap checker - the same
design that sits inside dlmalloc and the mallocs you use every day, minus the OS
integration and thread safety they layer on top. That is a real allocator, and it is
yours.
al := NewAllocator(128)a, _ := al.Malloc(24) // 8b, _ := al.Malloc(8) // 48c, _ := al.Malloc(40) // 72al.Set(b, 0x2A)al.Free(b)d, _ := al.Calloc(8) // 48 again, zeroedal.Free(a); al.Free(d); al.Free(c)// Dump()=="0:128:F"; Check()==nil; Stats().AllocBlocks==0