1
I’m having a hard time getting the logic of how to remove all nodes from a circular list, if someone could give a brief explanation of concept and / or point out the errors in the code I’ve already done would be very grateful :
int freelist ( Node ** list ) {
if ( empty ( list ) ) {
return 0;
}
if ( ( * list ) == ( * list ) -> next ) {
free ( * list );
( * list ) = NULL;
return 1;
}
Node * tmp = NULL, * aux = ( * list ) -> next;
while ( aux != ( * list ) ) {
tmp = aux;
aux = aux -> next;
free ( tmp );
}
// ( * list ) = NULL;
return 1;
}
If the list contains only one item the function works perfectly, already if more than one it does not delete them ... ( Full code here )
You can post the full code so we can reproduce your code?
– Woss
Ghostbin.com/Paste/bmxv4
– Luis Souza