On Sun, 23 Mar 2008, Manish Katiyar wrote:
> On Sun, Mar 23, 2008 at 12:46 PM, Robert P. J. Day
> <[EMAIL PROTECTED]> wrote:
> >
> > i'm sure i'm misreading something, but when i look at the macro
> > definition of "__list_for_each" in list.h:
> >
> > #define __list_for_each(pos, head) \
> > for (pos = (head)->next; pos != (head); pos = pos->next)
> >
> > i could swear that this traversal will visit each node in the list
> > except for the initial head element.
> >
> > look closely: given a starting address of "head", the
> > initialization starts things off at (head)->next, and continues
> > traversing as long as pos != head. so wouldn't this traversal end up
> > *not* visiting the list element addressed by "head" itself? or is
> > that what it's supposed to do?
>
> "Linux kernel development" - Robert Love has a nice detailed
> explaination of it.
ironically, that's the very book i have open in front of me at the
moment and which is confusing me, since robert writes (near the bottom
of p. 347):
"To traverse the list, simply pick an element and follow the pointers
until you get back to the original element. This removes the need for
a special head pointer."
however, as you explain it, that "sentinel" element *is* a special
kind of head pointer. so how to explain this discrepancy?
rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
Have classroom, will lecture.
http://crashcourse.ca Waterloo, Ontario, CANADA
========================================================================
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [EMAIL PROTECTED]
Please read the FAQ at http://kernelnewbies.org/FAQ