Re:Deconstructing K&R C Is Dead (2015)
by haberman on Thursday May 19, 2016 @02:16AM
(#11728376)
Yep! To do this properly requires something more like:
[ Parent
| on HN ]
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!