add realloc routine. fix primitives to use allocator