my implementation of the memory allocation system