Lines Matching refs:list
3 some simple double linked list macros
27 /* hook into the front of the list */
28 #define DLIST_ADD(list, p) \
30 if (!(list)) { \
31 (list) = (p); \
34 (list)->prev = (p); \
35 (p)->next = (list); \
37 (list) = (p); \
41 /* remove an element from a list - element doesn't have to be in list. */
42 #define DLIST_REMOVE(list, p) \
44 if ((p) == (list)) { \
45 (list) = (p)->next; \
46 if (list) { \
47 (list)->prev = NULL; \
57 if ((p) != (list)) { \
62 /* promote an element to the top of the list */
63 #define DLIST_PROMOTE(list, p) \
65 DLIST_REMOVE(list, p); \
66 DLIST_ADD(list, p); \
69 /* hook into the end of the list - needs a tmp pointer */
70 #define DLIST_ADD_END(list, p, type) \
72 if (!(list)) { \
73 (list) = (p); \
77 for (tmp = (list); tmp->next; tmp = tmp->next) { \
86 /* insert 'p' after the given element 'el' in a list. If el is NULL then
88 #define DLIST_ADD_AFTER(list, p, el) \
90 if (!(list) || !(el)) { \
91 DLIST_ADD(list, p); \
102 /* demote an element to the end of the list, needs a tmp pointer */
103 #define DLIST_DEMOTE(list, p, type) \
105 DLIST_REMOVE(list, p); \
106 DLIST_ADD_END(list, p, type); \
109 /* concatenate two lists - putting all elements of the 2nd list at the
110 end of the first list */
128 * first list */
147 #define DLIST_FOR_EACH(p, list) \
148 for ((p) = (list); (p) != NULL; (p) = (p)->next)
150 #define DLIST_FOR_EACH_SAFE(p, q, list) \
151 for ((p) = (list), (q) = (p) != NULL ? (p)->next : NULL; \