Programming malloc from scratch, as Dan Luu does in this blog post. Ported to mmap and OS X, because sbrk is deprecated there.
mmap
sbrk
Just use your system’s malloc. Seriously.