MAINT: move memory allocator functions to own file alloc.c