1. add a memory allocator. 2. replace malloc and free with new memory allocator