diff options
author | David Lamparter <equinox@diac24.net> | 2012-04-16 18:24:40 +0200 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2012-04-16 18:24:43 +0200 |
commit | d75318cc8de91d94649106f4ea3122d0d21ac9eb (patch) | |
tree | 6d7c674c4026bccd1384e60ee228d8d67750fbf7 /lib/linklist.h | |
parent | 6e493a44836d3b034ed3421e866878de3fbfcc5b (diff) | |
parent | 48d8bea8b7c83cf186460f711ab166455b5ed676 (diff) |
isisd: merge osr/google-is-is
this is essentially half of a rewrite of isisd. please note that a lot
of things are still broken and isisd is not ready for production use.
Diffstat (limited to 'lib/linklist.h')
-rw-r--r-- | lib/linklist.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/linklist.h b/lib/linklist.h index cc6867cd..f0ae3625 100644 --- a/lib/linklist.h +++ b/lib/linklist.h @@ -54,9 +54,9 @@ struct list void (*del) (void *val); }; -#define listnextnode(X) ((X)->next) -#define listhead(X) ((X)->head) -#define listtail(X) ((X)->tail) +#define listnextnode(X) ((X) ? ((X)->next) : NULL) +#define listhead(X) ((X) ? ((X)->head) : NULL) +#define listtail(X) ((X) ? ((X)->tail) : NULL) #define listcount(X) ((X)->count) #define list_isempty(X) ((X)->head == NULL && (X)->tail == NULL) #define listgetdata(X) (assert((X)->data != NULL), (X)->data) @@ -88,10 +88,10 @@ extern void list_add_list (struct list *, struct list *); * It is safe to delete the listnode using this macro. */ #define ALL_LIST_ELEMENTS(list,node,nextnode,data) \ - (node) = listhead(list); \ + (node) = listhead(list), ((data) = NULL); \ (node) != NULL && \ ((data) = listgetdata(node),(nextnode) = listnextnode(node), 1); \ - (node) = (nextnode) + (node) = (nextnode), ((data) = NULL) /* read-only list iteration macro. * Usage: as per ALL_LIST_ELEMENTS, but not safe to delete the listnode Only @@ -100,9 +100,9 @@ extern void list_add_list (struct list *, struct list *); * of previous macro. */ #define ALL_LIST_ELEMENTS_RO(list,node,data) \ - (node) = listhead(list); \ + (node) = listhead(list), ((data) = NULL);\ (node) != NULL && ((data) = listgetdata(node), 1); \ - (node) = listnextnode(node) + (node) = listnextnode(node), ((data) = NULL) /* these *do not* cleanup list nodes and referenced data, as the functions * do - these macros simply {de,at}tach a listnode from/to a list. |