chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add a snprinf wrapper which checks that the buffer was big enough
[elogind.git]
/
src
/
shared
/
list.h
diff --git
a/src/shared/list.h
b/src/shared/list.h
index c020f7e9369abe4eb89bb9d02d06722c0be5eecb..2939216adb60ef0aa43015421d3c9631de206a6e 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 { \
@@
-130,6
+138,18
@@
#define LIST_FOREACH_AFTER(name,i,p) \
for ((i) = (p)->name##_next; (i); (i) = (i)->name##_next)
#define LIST_FOREACH_AFTER(name,i,p) \
for ((i) = (p)->name##_next; (i); (i) = (i)->name##_next)
+/* Iterate through all the members of the list p is included in, but skip over p */
+#define LIST_FOREACH_OTHERS(name,i,p) \
+ for (({ \
+ (i) = (p); \
+ while ((i) && (i)->name##_prev) \
+ (i) = (i)->name##_prev; \
+ if ((i) == (p)) \
+ (i) = (p)->name##_next; \
+ }); \
+ (i); \
+ (i) = (i)->name##_next == (p) ? (p)->name##_next : (i)->name##_next)
+
/* Loop starting from p->next until p->prev.
p can be adjusted meanwhile. */
#define LIST_LOOP_BUT_ONE(name,i,head,p) \
/* Loop starting from p->next until p->prev.
p can be adjusted meanwhile. */
#define LIST_LOOP_BUT_ONE(name,i,head,p) \