[<<][c][>>][..]
Tue Sep 14 09:35:46 CEST 2010

Reinventing linked lists

Yes, I know i deserve to be slapped when implementing (sorted) linked
lists in C, but really, sometimes it's just easier to just write it
down.

Trouble is, this is error prone.  I _think_ I can just write it down
but there's always some bug in the code that's not caught by the type
system.  Double pointers are notorious for this.  See the following:

    struct timeout_list **tol = &a->timeouts;
    while ((*tol) && ((*tol)->time < at)) { (*tol) = (*tol)->next; }

What I really wanted to write is:

    struct timeout_list **tol = &a->timeouts;
    while ((*tol) && ((*tol)->time < at)) { tol = &((*tol)->next); }

The latter iterates, while the former removes elements!




[Reply][About]
[<<][c][>>][..]