Simple memory allocator from K&R (5.5)