Hey, I have hit a brick wall in figuring out why my list destructor doesn't work. I'm pretty sure I'm deleting the list correctly but I'm unsure on how I should also free the memory of the linked list.
Here's my code for the destructor function
Code:
void releaseTB (TB tb) {
TB curr = tb;
TB tmp;
while (curr != NULL) {
tmp = curr->next;
free(curr->item);
curr = tmp;
}
}
Basically the code is meant to free the memory occupied by the list and that it's an error to access the list once I've called this function. The item is a malloced string.
Can anyone give me pointers on how I can fix the problem with my destructor function?