Memory management code in C++ for an operating system