From: Martin Mares Date: Sat, 19 Feb 2005 17:11:25 +0000 (+0000) Subject: Added clist walking macros with embedded C99 declaration of the iterator X-Git-Tag: holmes-import~824 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=02c66f9ec998f483accc05fd5bf67609e73e333f;p=libucw.git Added clist walking macros with embedded C99 declaration of the iterator variable. --- diff --git a/lib/clists.h b/lib/clists.h index 4fa09546..846752fc 100644 --- a/lib/clists.h +++ b/lib/clists.h @@ -1,7 +1,7 @@ /* * UCW Library -- Circular Linked Lists * - * (c) 2003 Martin Mares + * (c) 2003--2005 Martin Mares * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. @@ -45,6 +45,8 @@ static inline int clist_empty(clist *l) #define CLIST_WALK(n,list) for(n=(void*)(list).head.next; (cnode*)(n) != &(list).head; n=(void*)((cnode*)(n))->next) #define CLIST_WALK_DELSAFE(n,list,tmp) for(n=(void*)(list).head.next; tmp=(void*)((cnode*)(n))->next, (cnode*)(n) != &(list).head; n=(void*)tmp) +#define CLIST_FOR_EACH(type,n,list) for(type n=(void*)(list).head.next; (cnode*)(n) != &(list).head; n=(void*)((cnode*)(n))->next) +#define CLIST_FOR_EACH_DELSAFE(type,n,list,tmp) for(type n=(void*)(list).head.next; tmp=(void*)((cnode*)(n))->next, (cnode*)(n) != &(list).head; n=(void*)tmp) static inline void clist_insert_after(cnode *what, cnode *after) {