Here I have developed memory block allocator which provides dynamic memory allocation and deallocation at user request. It provides an API similar to malloc(size_t i_size) and free(void* i_ptr). We require a Heap Manager because memory allocation usually happens with an overhead and without proper management, there is a risk of fragmentation.
The full code is available here: Github
So there are three main functions: myAlloc( which allocates memory from the heap in given chunk size), myFree ( which deallocates memory previously given, from a pointer) and myCollect (who walks the list of descriptors of free memory blocks and checks if it can collapse blocks that adjoin into larger blocks).