list.h: document the more convenient iteration method

Dimi Paun dimi at lattica.com
Wed May 18 07:12:59 CDT 2005


On Wed, 2005-05-18 at 08:01 -0400, Dimi Paun wrote:
>   *   struct list *cursor;
> - *   LIST_FOR_EACH( cursor, &global_gadgets )
> + *   LIST_FOR_EACH_ENTRY( cursor, &global_gadgets, struct gadget *,
> gadget )
>   *   {

Looking at this, why do we need cursor at all for the
LIST_FOR_EACH_ENTRY? Also the type and iteration var
should come first, to be simiar for loops in pretty 
much any language out there. I think it should just be:
    LIST_FOR_EACH_ENTRY( struct gadget *, gadget, &global_gadgets )

Ah, I see now the problem. We would need to end it with LIST_END
instead of just doing {...}. Not such a big deal, we do the same
for server requests too :)

But I can see why we would like to keep cursor. If so, it should
come at the end:
    LIST_FOR_EACH_ENTRY(struct gadget *,gadget,&global_gadgets,cursor)

-- 
Dimi Paun <dimi at lattica.com>
Lattica, Inc.




More information about the wine-devel mailing list