Lines Matching defs:list
37 #include "list.h"
40 struct list {
42 struct list *l_next;
45 /* Add an element to a list */
47 list_add(list_t **list, void *data)
53 le->l_next = *list;
54 *list = le;
57 /* Add an element to a sorted list */
59 slist_add(list_t **list, void *data, int (*cmp)(void *, void *))
63 for (nextp = list; *nextp; nextp = &((*nextp)->l_next)) {
79 list_remove(list_t **list, void *data, int (*cmp)(void *, void *, void *),
88 for (le = *list, le2 = list; le; le2 = &le->l_next, le = le->l_next) {
101 list_free(list_t *list, void (*datafree)(void *, void *), void *private)
105 while (list) {
106 le = list;
107 list = list->l_next;
119 list_iter(list_t *list, int (*func)(void *, void *), void *private)
125 while (list) {
126 lnext = list->l_next;
127 if ((cbrc = func(list->l_data, private)) < 0)
130 list = lnext;
144 list_count(list_t *list)
146 return (list_iter(list, list_count_cb, NULL));
150 list_empty(list_t *list)
152 return (list == NULL);
156 list_find(list_t *list, void *tmpl, int (*cmp)(void *, void *))
158 for (; list; list = list->l_next) {
159 if (cmp(list->l_data, tmpl) == 0)
160 return (list->l_data);
167 list_first(list_t *list)
169 return (list ? list->l_data : NULL);