5 ms·
I'm not sure what you are trying to achieve by using the infinite loop. There's a more direct way. void free_circularly_linked_list(struct node *head)
by ericbb 10y ago
I'm not sure what you are trying to achieve by using the infinite loop. There's a more direct way.
void free_circularly_linked_list(struct node *head)
{
struct node *a = head->next;
while (a != head) {
struct node *b = a->next;
free(a);
a = b;
}
free(head);
}
Great example, by the way!