Lines Matching refs:list
1 /* llist.c - Linked list functions
3 * Linked list structures have a next pointer as their first element.
26 // Call a function (such as free()) on each element of a linked list.
27 void llist_traverse(void *list, void (*using)(void *node))
29 void *old = list;
31 while (list) {
32 void *pop = llist_pop(&list);
35 // End doubly linked list too.
36 if (old == list) break;
40 // Return the first item from the list, advancing the list (which must be called
41 // as &list)
42 void *llist_pop(void *list)
47 void **llist = (void **)list;
54 // Remove first item from &list and return it
55 void *dlist_pop(void *list)
57 struct double_list **pdlist = (struct double_list **)list, *dlist = *pdlist;
70 // remove last item from &list and return it (stack pop)
71 void *dlist_lpop(void *list)
73 struct double_list *dl = *(struct double_list **)list;
79 if (!dl) *(void **)list = 0;
85 void dlist_add_nomalloc(struct double_list **list, struct double_list *new)
87 if (*list) {
88 new->next = *list;
89 new->prev = (*list)->prev;
90 (*list)->prev->next = new;
91 (*list)->prev = new;
92 } else *list = new->next = new->prev = new;
96 // Add an entry to the end of a doubly linked list
97 struct double_list *dlist_add(struct double_list **list, char *data)
102 dlist_add_nomalloc(list, new);
107 // Terminate circular list for traversal in either direction. Returns end *.
108 void *dlist_terminate(void *list)
110 struct double_list *end = list;
112 if (!list) return 0;