Studying Hare's builtin functions for memory allocation...
If the debug tag's set allocates additional space for the pointer & size of the preceding allocation, whilst enforcing alignment to some pagesize reading from the `envp` array on startup.
If compiled against LibC it defers to its memory allocation functions.
As for the self-hosted memory allocator... `malloc` returns null for size of 0, & defers primarily to kernel-specific code for massive allocations.
1/2?
Normally though Hare's malloc rounds the size to a power of 2 & looks up that "bucket". If null it falls back to arena allocation, or kernel-allocating a new arena. Otherwise it pops that entry off that bin's linkedlist & validates it. Regardless it saves the allocated size to this "chunk" & increments a profiling counter.
Meanwhile free locates the header fields from the pointer, decrements that counter, considers asking the kernel to free it, & pushes it onto the correct bin.
2/3!