implemented MemoryPool and MallocAllocator

Also added some other code around these classes that helps implementing them in
a streamlined fashion.