chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
shared: add minimal firewall manipulation helpers for establishing NAT rules, using...
[elogind.git]
/
src
/
shared
/
list.h
diff --git
a/src/shared/list.h
b/src/shared/list.h
index e55b91cea4ad9c0184ee07390ba78a11c9c81a0a..f0458b54e24d0d5235aa736428c12e9dfa6c0d60 100644
(file)
--- a/
src/shared/list.h
+++ b/
src/shared/list.h
@@
-55,6
+55,14
@@
*_head = _item; \
} while(false)
*_head = _item; \
} while(false)
+/* Append an item to the list */
+#define LIST_APPEND(name,head,item) \
+ do { \
+ typeof(*(head)) *_tail; \
+ LIST_FIND_TAIL(name,head,_tail); \
+ LIST_INSERT_AFTER(name,head,_tail,item); \
+ } while(false)
+
/* Remove an item from the list */
#define LIST_REMOVE(name,head,item) \
do { \
/* Remove an item from the list */
#define LIST_REMOVE(name,head,item) \
do { \
@@
-75,20
+83,26
@@
#define LIST_FIND_HEAD(name,item,head) \
do { \
typeof(*(item)) *_item = (item); \
#define LIST_FIND_HEAD(name,item,head) \
do { \
typeof(*(item)) *_item = (item); \
- assert(_item); \
- while (_item->name##_prev) \
- _item = _item->name##_prev; \
- (head) = _item; \
+ if (!_item) \
+ (head) = NULL; \
+ else { \
+ while (_item->name##_prev) \
+ _item = _item->name##_prev; \
+ (head) = _item; \
+ } \
} while (false)
/* Find the tail of the list */
#define LIST_FIND_TAIL(name,item,tail) \
do { \
typeof(*(item)) *_item = (item); \
} while (false)
/* Find the tail of the list */
#define LIST_FIND_TAIL(name,item,tail) \
do { \
typeof(*(item)) *_item = (item); \
- assert(_item); \
- while (_item->name##_next) \
- _item = _item->name##_next; \
- (tail) = _item; \
+ if (!_item) \
+ (tail) = NULL; \
+ else { \
+ while (_item->name##_next) \
+ _item = _item->name##_next; \
+ (tail) = _item; \
+ } \
} while (false)
/* Insert an item after another one (a = where, b = what) */
} while (false)
/* Insert an item after another one (a = where, b = what) */