Lines Matching defs:list

39 #include <list.h>
44 * list_append() takes in a list (type **) and a pointer to an item to add
45 * to the list and returns a new list with the new item appended on the
46 * end. The list is NULL terminated. If there was an error, NULL is
47 * returned. For reasonable efficiency, the list will be allocated
51 list_append(void **list, void *item)
54 syslog(LOG_DEBUG, "list_append(0x%x, 0x%x)", list, item);
57 return (list);
59 if (list == NULL) {
60 list = (void **)calloc(_list_increment, sizeof (void *));
61 (void) memset(list, NULL, (_list_increment * sizeof (void *)));
62 list[0] = item;
66 for (count = 0; list[count] != NULL; count++);
77 for (count = 0; list[count] != NULL; count++)
78 new_list[count] = list[count];
79 free(list);
80 list = new_list;
82 list[count] = item;
84 return (list);
89 list_append_unique(void **list, void *item, int (*cmp)(void *, void*))
91 if (list_locate(list, cmp, item))
92 return (list);
94 list = list_append(list, item);
95 return (list);
100 * list_locate() iterates through the list passed in and uses the comparison
101 * routine and element passed in to find an element in the list. It
105 list_locate(void **list, int (*compair)(void *, void *), void *element)
112 if (list != NULL)
113 for (current = 0; list[current] != NULL; current++)
114 if ((compair)(list[current], element) == 0)
115 return (list[current]);
122 * and creates a new list with items from list2 appended on the end of
123 * the list of items from list1. The result is a list (type **). If
129 void **list = NULL;
145 if ((list = (void **)calloc((new_size), sizeof (void *)))
149 (void) memset(list, NULL, (new_size * sizeof (void *)));
152 list[count++] = list1[size1];
154 list[count++] = list2[size2];
157 return (list);
162 * list_iterate() take in a list, pointer to a function, and variable number
163 * of arguements following. list_iterate() will iterate through the list
165 * to the current item in the list and the second argument being a va_list
172 list_iterate(void **list, int (*vfunc)(void *, va_list), ...)
178 syslog(LOG_DEBUG, "list_iterate(0x%x, 0x%x)", list, vfunc);
180 if (list != NULL)
181 while (list[current] != NULL) {
185 rc += (vfunc)(list[current++], ap);