I'm having some trouble implementing my own dynamic memory allocator using an Implicit list to track free blocks in c. ****Specifically I'm having problems with implementing realloc and changing the code from find-fit/first-fit to next-fit. Best-fit would be ideal but lets just say next fit for now. I've got everything thing else down, its just those two items specifically...
more info...
I'm trying to implement my own version of a dynamic memory allocator with my own versions of malloc, free, and realloc...There are four methods used to keep track of free blocks in a dynamic memory allocator, the first one of these which I have here is an Implicit list, which uses a header. For finding a free block in an Implicit list there are several placement policies which can be enacted in an Implicit list. The first of which is called first fit or find fit which is located in the code below...it searches the list from the beginning, and chooses the first free block that fits. The next method is called next fit which I am having trouble trying to implement, and this method is similar to first fit, but instead of starting each search at the beginning of the list, it starts each search where the previous search left off. Finally there is Best fit...this would be the ideal method for me but I know it is rather complicated and pretty difficult, so I will take just next fit, but, if there is someone out there who knows how to implement best fit in an implicit list PLEASE, feel free to post it. Best fit examines every free block and chooses the free block with the smallest size that fits...I do know that for Best fit it is possible to eliminate footers in allocated blocks...mostly cause they are really not necessary ...I'm just not exactly sure how to do this...
I understand this is a lot of code but I just wanted to put everything in all at once so nothing gets missed.
I left space for realloc which returns NULL and is somewhere in the middle of the code and find_ fit which I want to change to the next_fit placement policy method is towards the bottom...
Any help would be greatly appreciated...Thank You.
The code is all in this website...sorry...I was having many problems posting the code here...even more so since it is so large...I just used google so it seems more authentic...
I've labeled the sections clearly in the code on the website so one should have no trouble finding the realloc and the find fit methods...