Recreating a simple version of malloc and free