This is a school assignment and I have most of it under control, but there is a small part that is creating a memory leak and I have no more ideas on how to fix it.
We have created a memory allocator, and the trouble part are this two functions.
This first one cannot be modified
void destroy (){
free():
tot_alloc = 0; }
This second one is the one I'm working on
void free(){
munmap(pool, PAGE_SIZE);
Page* f = this;
f = f->prev;
if (f != NULL)
f->destroy();
}
I have written all of the free() function and was asked in the assignment to call destroy(). I realize that this function is not destroying the first "this" because immediately is going to f->prev but I have no clue how to make it first destroy this and the go to prev.
I hope this is not a too silly question.
Many thanks!
Nico