Oh gosh this reminds me of a college project where we had to build the heap allocator in C. This is giving me nightmares