/* The previous example was slow, ugly and wrong!!! */
/*
* We pass in a ptr this time
*/
static struct ll * first;
void add_ll_element_to_end(struct link_list *new_member)
{
struct ll * next;
if (first) {
for (next = first->next; next->next; next = next->next);
next->next = new_member;
} else {
first = new_member;
}
new_member->next = NULL;
}
next slide