Move the memory related functions out of common.h into their own header file