Extract memory.c from misc2.c