Lines Matching refs:list
26 * Generic doubly-linked list implementation
29 #include <sys/list.h>
41 extern list_node_t *list_d2l(list_t *list, void *obj);
48 #define list_insert_after_node(list, node, object) { \
49 list_node_t *lnew = list_d2l(list, object); \
56 #define list_insert_before_node(list, node, object) { \
57 list_node_t *lnew = list_d2l(list, object); \
70 list_create(list_t *list, size_t size, size_t offset)
72 ASSERT(list);
76 list->list_size = size;
77 list->list_offset = offset;
78 list->list_head.list_next = list->list_head.list_prev =
79 &list->list_head;
83 list_destroy(list_t *list)
85 list_node_t *node = &list->list_head;
87 ASSERT(list);
88 ASSERT(list->list_head.list_next == node);
89 ASSERT(list->list_head.list_prev == node);
95 list_insert_after(list_t *list, void *object, void *nobject)
98 list_insert_head(list, nobject);
100 list_node_t *lold = list_d2l(list, object);
101 list_insert_after_node(list, lold, nobject);
106 list_insert_before(list_t *list, void *object, void *nobject)
109 list_insert_tail(list, nobject);
111 list_node_t *lold = list_d2l(list, object);
112 list_insert_before_node(list, lold, nobject);
117 list_insert_head(list_t *list, void *object)
119 list_node_t *lold = &list->list_head;
120 list_insert_after_node(list, lold, object);
124 list_insert_tail(list_t *list, void *object)
126 list_node_t *lold = &list->list_head;
127 list_insert_before_node(list, lold, object);
131 list_remove(list_t *list, void *object)
133 list_node_t *lold = list_d2l(list, object);
134 ASSERT(!list_empty(list));
140 list_remove_head(list_t *list)
142 list_node_t *head = list->list_head.list_next;
143 if (head == &list->list_head)
146 return (list_object(list, head));
150 list_remove_tail(list_t *list)
152 list_node_t *tail = list->list_head.list_prev;
153 if (tail == &list->list_head)
156 return (list_object(list, tail));
160 list_head(list_t *list)
162 if (list_empty(list))
164 return (list_object(list, list->list_head.list_next));
168 list_tail(list_t *list)
170 if (list_empty(list))
172 return (list_object(list, list->list_head.list_prev));
176 list_next(list_t *list, void *object)
178 list_node_t *node = list_d2l(list, object);
180 if (node->list_next != &list->list_head)
181 return (list_object(list, node->list_next));
187 list_prev(list_t *list, void *object)
189 list_node_t *node = list_d2l(list, object);
191 if (node->list_prev != &list->list_head)
192 return (list_object(list, node->list_prev));
198 * Insert src list after dst list. Empty src list thereafter.
217 /* empty src list */
248 list_is_empty(list_t *list)
250 return (list_empty(list));