Still having problems understanding how to free the memory for a single linked list. I went over the presentation and put together this snippet of code:
void destroy(sllnode* head)
{
// *base case* if you've reached a null pointer, stop
if(head == NULL)
{
return;
}
// *recusive case*
else
{
// destroy the rest of the list
return destroy(head->next);
// Free the current node
free(head);
return;
}
}
I still get memory leaks with this so I know I'm not doing something right. Thanks in advance.