basic C heap allocator, including malloc, realloc and free