Lines Matching refs:list

25     list_t *list = (list_t *) osi_calloc(sizeof(list_t));  in list_new_internal()  local
26 if (!list) { in list_new_internal()
30 list->head = list->tail = NULL; in list_new_internal()
31 list->length = 0; in list_new_internal()
32 list->free_cb = callback; in list_new_internal()
33 return list; in list_new_internal()
41 void list_free(list_t *list) in list_free() argument
43 if (!list) { in list_free()
47 list_clear(list); in list_free()
48 osi_free(list); in list_free()
51 bool list_is_empty(const list_t *list) in list_is_empty() argument
53 assert(list != NULL); in list_is_empty()
54 return (list->length == 0); in list_is_empty()
57 bool list_contains(const list_t *list, const void *data) in list_contains() argument
59 assert(list != NULL); in list_contains()
62 for (const list_node_t *node = list_begin(list); node != list_end(list); node = list_next(node)) { in list_contains()
71 list_node_t *list_get_node(const list_t *list, const void *data) in list_get_node() argument
73 assert(list != NULL); in list_get_node()
76 for (list_node_t *node = list_begin(list); node != list_end(list); node = list_next(node)) { in list_get_node()
86 size_t list_length(const list_t *list) in list_length() argument
88 assert(list != NULL); in list_length()
89 return list->length; in list_length()
92 void *list_front(const list_t *list) in list_front() argument
94 assert(list != NULL); in list_front()
95 assert(!list_is_empty(list)); in list_front()
97 return list->head->data; in list_front()
100 void *list_back(const list_t *list) { in list_back() argument
101 assert(list != NULL); in list_back()
102 assert(!list_is_empty(list)); in list_back()
104 return list->tail->data; in list_back()
107 list_node_t *list_back_node(const list_t *list) { in list_back_node() argument
108 assert(list != NULL); in list_back_node()
109 assert(!list_is_empty(list)); in list_back_node()
111 return list->tail; in list_back_node()
114 bool list_insert_after(list_t *list, list_node_t *prev_node, void *data) { in list_insert_after() argument
115 assert(list != NULL); in list_insert_after()
126 if (list->tail == prev_node) { in list_insert_after()
127 list->tail = node; in list_insert_after()
129 ++list->length; in list_insert_after()
133 bool list_prepend(list_t *list, void *data) in list_prepend() argument
135 assert(list != NULL); in list_prepend()
142 node->next = list->head; in list_prepend()
144 list->head = node; in list_prepend()
145 if (list->tail == NULL) { in list_prepend()
146 list->tail = list->head; in list_prepend()
148 ++list->length; in list_prepend()
152 bool list_append(list_t *list, void *data) in list_append() argument
154 assert(list != NULL); in list_append()
163 if (list->tail == NULL) { in list_append()
164 list->head = node; in list_append()
165 list->tail = node; in list_append()
167 list->tail->next = node; in list_append()
168 list->tail = node; in list_append()
170 ++list->length; in list_append()
174 bool list_remove(list_t *list, void *data) in list_remove() argument
176 assert(list != NULL); in list_remove()
179 if (list_is_empty(list)) { in list_remove()
183 if (list->head->data == data) { in list_remove()
184 list_node_t *next = list_free_node(list, list->head); in list_remove()
185 if (list->tail == list->head) { in list_remove()
186 list->tail = next; in list_remove()
188 list->head = next; in list_remove()
192 …for (list_node_t *prev = list->head, *node = list->head->next; node; prev = node, node = node->nex… in list_remove()
194 prev->next = list_free_node(list, node); in list_remove()
195 if (list->tail == node) { in list_remove()
196 list->tail = prev; in list_remove()
204 bool list_delete(list_t *list, void *data) in list_delete() argument
206 assert(list != NULL); in list_delete()
209 if (list_is_empty(list)) { in list_delete()
213 if (list->head->data == data) { in list_delete()
214 list_node_t *next = list_delete_node(list, list->head); in list_delete()
215 if (list->tail == list->head) { in list_delete()
216 list->tail = next; in list_delete()
218 list->head = next; in list_delete()
222 …for (list_node_t *prev = list->head, *node = list->head->next; node; prev = node, node = node->nex… in list_delete()
224 prev->next = list_delete_node(list, node); in list_delete()
225 if (list->tail == node) { in list_delete()
226 list->tail = prev; in list_delete()
234 void list_clear(list_t *list) in list_clear() argument
236 assert(list != NULL); in list_clear()
237 for (list_node_t *node = list->head; node; ) { in list_clear()
238 node = list_free_node(list, node); in list_clear()
240 list->head = NULL; in list_clear()
241 list->tail = NULL; in list_clear()
242 list->length = 0; in list_clear()
245 list_node_t *list_foreach(const list_t *list, list_iter_cb callback, void *context) in list_foreach() argument
247 assert(list != NULL); in list_foreach()
250 for (list_node_t *node = list->head; node; ) { in list_foreach()
260 list_node_t *list_begin(const list_t *list) in list_begin() argument
262 assert(list != NULL); in list_begin()
263 return list->head; in list_begin()
266 list_node_t *list_end(UNUSED_ATTR const list_t *list) in list_end() argument
268 assert(list != NULL); in list_end()
284 list_node_t *list_free_node(list_t *list, list_node_t *node) in list_free_node() argument
286 assert(list != NULL); in list_free_node()
291 if (list->free_cb) { in list_free_node()
292 list->free_cb(node->data); in list_free_node()
295 --list->length; in list_free_node()
301 list_node_t *list_delete_node(list_t *list, list_node_t *node) in list_delete_node() argument
303 assert(list != NULL); in list_delete_node()
309 --list->length; in list_delete_node()