version 1.1.1.1, 2012/02/21 17:26:12
|
version 1.1.1.4, 2016/11/02 10:09:11
|
Line 54 struct list
|
Line 54 struct list
|
void (*del) (void *val); |
void (*del) (void *val); |
}; |
}; |
|
|
#define listnextnode(X) ((X)->next) | #define listnextnode(X) ((X) ? ((X)->next) : NULL) |
#define listhead(X) ((X)->head) | #define listhead(X) ((X) ? ((X)->head) : NULL) |
#define listtail(X) ((X)->tail) | #define listtail(X) ((X) ? ((X)->tail) : NULL) |
#define listcount(X) ((X)->count) |
#define listcount(X) ((X)->count) |
#define list_isempty(X) ((X)->head == NULL && (X)->tail == NULL) |
#define list_isempty(X) ((X)->head == NULL && (X)->tail == NULL) |
#define listgetdata(X) (assert((X)->data != NULL), (X)->data) |
#define listgetdata(X) (assert((X)->data != NULL), (X)->data) |
Line 68 extern void list_free (struct list *);
|
Line 68 extern void list_free (struct list *);
|
extern void listnode_add (struct list *, void *); |
extern void listnode_add (struct list *, void *); |
extern void listnode_add_sort (struct list *, void *); |
extern void listnode_add_sort (struct list *, void *); |
extern void listnode_add_after (struct list *, struct listnode *, void *); |
extern void listnode_add_after (struct list *, struct listnode *, void *); |
|
extern void listnode_move_to_tail (struct list *, struct listnode *); |
extern void listnode_delete (struct list *, void *); |
extern void listnode_delete (struct list *, void *); |
extern struct listnode *listnode_lookup (struct list *, void *); |
extern struct listnode *listnode_lookup (struct list *, void *); |
extern void *listnode_head (struct list *); |
extern void *listnode_head (struct list *); |
Line 88 extern void list_add_list (struct list *, struct list
|
Line 89 extern void list_add_list (struct list *, struct list
|
* It is safe to delete the listnode using this macro. |
* It is safe to delete the listnode using this macro. |
*/ |
*/ |
#define ALL_LIST_ELEMENTS(list,node,nextnode,data) \ |
#define ALL_LIST_ELEMENTS(list,node,nextnode,data) \ |
(node) = listhead(list); \ | (node) = listhead(list), ((data) = NULL); \ |
(node) != NULL && \ |
(node) != NULL && \ |
((data) = listgetdata(node),(nextnode) = listnextnode(node), 1); \ | ((data) = listgetdata(node),(nextnode) = node->next, 1); \ |
(node) = (nextnode) | (node) = (nextnode), ((data) = NULL) |
|
|
/* read-only list iteration macro. |
/* read-only list iteration macro. |
* Usage: as per ALL_LIST_ELEMENTS, but not safe to delete the listnode Only |
* Usage: as per ALL_LIST_ELEMENTS, but not safe to delete the listnode Only |
Line 100 extern void list_add_list (struct list *, struct list
|
Line 101 extern void list_add_list (struct list *, struct list
|
* of previous macro. |
* of previous macro. |
*/ |
*/ |
#define ALL_LIST_ELEMENTS_RO(list,node,data) \ |
#define ALL_LIST_ELEMENTS_RO(list,node,data) \ |
(node) = listhead(list); \ | (node) = listhead(list), ((data) = NULL);\ |
(node) != NULL && ((data) = listgetdata(node), 1); \ |
(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 |
/* 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. |
* do - these macros simply {de,at}tach a listnode from/to a list. |
Line 112 extern void list_add_list (struct list *, struct list
|
Line 113 extern void list_add_list (struct list *, struct list
|
#define LISTNODE_ATTACH(L,N) \ |
#define LISTNODE_ATTACH(L,N) \ |
do { \ |
do { \ |
(N)->prev = (L)->tail; \ |
(N)->prev = (L)->tail; \ |
|
(N)->next = NULL; \ |
if ((L)->head == NULL) \ |
if ((L)->head == NULL) \ |
(L)->head = (N); \ |
(L)->head = (N); \ |
else \ |
else \ |