diff options
author | Pavel Machek <pavel@ucw.cz> | 1998-07-09 21:35:23 +0200 |
---|---|---|
committer | Pavel Machek <pavel@ucw.cz> | 1998-07-09 21:35:23 +0200 |
commit | aea2dcabdc4ed80172ac8d4f5c4d31bc8607d1e7 (patch) | |
tree | 641f1ceb251e572d2e1b69cba9532d8767d027bb /lib | |
parent | 962ba482fd7bba97cf13a96105503efff4dcb88a (diff) | |
download | bird-aea2dcabdc4ed80172ac8d4f5c4d31bc8607d1e7.tar bird-aea2dcabdc4ed80172ac8d4f5c4d31bc8607d1e7.zip |
Adding walk list which permits you to delete entries.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lists.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/lists.h b/lib/lists.h index 3230724..ae02ad4 100644 --- a/lib/lists.h +++ b/lib/lists.h @@ -20,8 +20,14 @@ typedef struct list { /* In fact two overlayed nodes */ #define NODE (node *) #define HEAD(list) ((void *)((list).head)) #define TAIL(list) ((void *)((list).tail)) -#define WALK_LIST(n,list) for((n)=HEAD(list);(NODE (n))->next; \ +#define WALK_LIST(n,list) for((NODE (n))=HEAD(list);(NODE (n))->next; \ n=(void *)((NODE (n))->next)) +#define WALK_LIST_DELSAFE(n,ne,list) \ + if ( ((NODE n) = HEAD(list)) ) \ + for( (NODE ne) = (NODE n)->next; \ + ne; \ + (NODE ne) = (NODE (n=ne))->next ) + #define EMPTY_LIST(list) (!(list).head->next) void add_tail(list *, node *); |