Naive Memory Allocator

I implemented the basic allocator implementation mentioned in the article mentioned previously.

This is a basic functional allocator. There are a few problems, I can directly figure that we would face.

  • freeing is O(n). so as we allocate more and more memory, we will take longer to free the blocks.
  • incase all blocks except the last one are freed and then we free the last one, programbreak is only moved till the end of this last block only.
  • all the already allocated headers still exist.
  • two consecutive free headers may be sufficient together but not alone, but they are checked seperately so none will be allocated and program break needs to be extended.

malloc() implementation

free() implementation

Conclusion

Now proceeding to an implicit free list allocator