chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
core: add "khash" API to src/basic/ (as wrapper around kernel AF_ALG)
[elogind.git]
/
src
/
basic
/
list.h
diff --git
a/src/basic/list.h
b/src/basic/list.h
index 760abcdab3bd087ca40f5cd5d055f5f687c60ac9..c3771a177f70e494b94d868a62056bc5d8f6e6be 100644
(file)
--- a/
src/basic/list.h
+++ b/
src/basic/list.h
@@
-1,5
+1,3
@@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
#pragma once
/***
#pragma once
/***
@@
-34,7
+32,7
@@
#define LIST_HEAD_INIT(head) \
do { \
(head) = NULL; } \
#define LIST_HEAD_INIT(head) \
do { \
(head) = NULL; } \
- while(false)
+ while
(false)
/* Initialize a list item */
#define LIST_INIT(name,item) \
/* Initialize a list item */
#define LIST_INIT(name,item) \
@@
-42,7
+40,7
@@
typeof(*(item)) *_item = (item); \
assert(_item); \
_item->name##_prev = _item->name##_next = NULL; \
typeof(*(item)) *_item = (item); \
assert(_item); \
_item->name##_prev = _item->name##_next = NULL; \
- } while(false)
+ } while
(false)
/* Prepend an item to the list */
#define LIST_PREPEND(name,head,item) \
/* Prepend an item to the list */
#define LIST_PREPEND(name,head,item) \
@@
-53,7
+51,7
@@
_item->name##_next->name##_prev = _item; \
_item->name##_prev = NULL; \
*_head = _item; \
_item->name##_next->name##_prev = _item; \
_item->name##_prev = NULL; \
*_head = _item; \
- } while(false)
+ } while
(false)
/* Append an item to the list */
#define LIST_APPEND(name,head,item) \
/* Append an item to the list */
#define LIST_APPEND(name,head,item) \
@@
-61,7
+59,7
@@
typeof(*(head)) *_tail; \
LIST_FIND_TAIL(name,head,_tail); \
LIST_INSERT_AFTER(name,head,_tail,item); \
typeof(*(head)) *_tail; \
LIST_FIND_TAIL(name,head,_tail); \
LIST_INSERT_AFTER(name,head,_tail,item); \
- } while(false)
+ } while
(false)
/* Remove an item from the list */
#define LIST_REMOVE(name,head,item) \
/* Remove an item from the list */
#define LIST_REMOVE(name,head,item) \
@@
-77,7
+75,7
@@
*_head = _item->name##_next; \
} \
_item->name##_next = _item->name##_prev = NULL; \
*_head = _item->name##_next; \
} \
_item->name##_next = _item->name##_prev = NULL; \
- } while(false)
+ } while
(false)
/* Find the head of the list */
#define LIST_FIND_HEAD(name,item,head) \
/* Find the head of the list */
#define LIST_FIND_HEAD(name,item,head) \
@@
-121,7
+119,7
@@
_b->name##_prev = _a; \
_a->name##_next = _b; \
} \
_b->name##_prev = _a; \
_a->name##_next = _b; \
} \
- } while(false)
+ } while
(false)
/* Insert an item before another one (a = where, b = what) */
#define LIST_INSERT_BEFORE(name,head,a,b) \
/* Insert an item before another one (a = where, b = what) */
#define LIST_INSERT_BEFORE(name,head,a,b) \
@@
-144,10
+142,12
@@
} else { \
if ((_b->name##_prev = _a->name##_prev)) \
_b->name##_prev->name##_next = _b; \
} else { \
if ((_b->name##_prev = _a->name##_prev)) \
_b->name##_prev->name##_next = _b; \
+ else \
+ *_head = _b; \
_b->name##_next = _a; \
_a->name##_prev = _b; \
} \
_b->name##_next = _a; \
_a->name##_prev = _b; \
} \
- } while(false)
+ } while
(false)
#define LIST_JUST_US(name,item) \
(!(item)->name##_prev && !(item)->name##_next) \
#define LIST_JUST_US(name,item) \
(!(item)->name##_prev && !(item)->name##_next) \