C++ implementation of a memory manager