I am trying to free a doubly linked list. This is the function I am using.
static void clean_list(particles * plist)
{
particles *n_list = plist;
particles *temp_nlist;
while(n_list){
temp_nlist = n_list->next;
free(n_list);
n_list = temp_nlist;
}
}
When I try to call this function in my program, the program hangs without returning from this function. Few things to note: plist is a doubly linked list with a prev
, a next
, a pointer to a struct which in turn has int and double as data and a linked list itself as member data. Do you think that since plist has pointers to other data, it hangs? In that case I have even tying freeing the pointer, and running the same clean_list
on the linked list which a member of plist. I tried searching around for a solution and I didn't find any. Please help.
next
never becomesNULL
). – cnicutar