• Home
  • Raw
  • Download

Lines Matching full:list

26  * SECTION:libkmod-list
27 * @short_description: general purpose list
38 static inline void list_node_append(struct list_node *list, in list_node_append() argument
41 if (list == NULL) { in list_node_append()
46 node->prev = list->prev; in list_node_append()
47 list->prev->next = node; in list_node_append()
48 list->prev = node; in list_node_append()
49 node->next = list; in list_node_append()
63 static inline void list_node_insert_after(struct list_node *list, in list_node_insert_after() argument
66 if (list == NULL) { in list_node_insert_after()
71 node->prev = list; in list_node_insert_after()
72 node->next = list->next; in list_node_insert_after()
73 list->next->prev = node; in list_node_insert_after()
74 list->next = node; in list_node_insert_after()
77 static inline void list_node_insert_before(struct list_node *list, in list_node_insert_before() argument
80 if (list == NULL) { in list_node_insert_before()
85 node->next = list; in list_node_insert_before()
86 node->prev = list->prev; in list_node_insert_before()
87 list->prev->next = node; in list_node_insert_before()
88 list->prev = node; in list_node_insert_before()
111 struct kmod_list *kmod_list_append(struct kmod_list *list, const void *data) in kmod_list_append() argument
120 list_node_append(list ? &list->node : NULL, &new->node); in kmod_list_append()
122 return list ? list : new; in kmod_list_append()
125 struct kmod_list *kmod_list_insert_after(struct kmod_list *list, in kmod_list_insert_after() argument
130 if (list == NULL) in kmod_list_insert_after()
131 return kmod_list_append(list, data); in kmod_list_insert_after()
138 list_node_insert_after(&list->node, &new->node); in kmod_list_insert_after()
140 return list; in kmod_list_insert_after()
143 struct kmod_list *kmod_list_insert_before(struct kmod_list *list, in kmod_list_insert_before() argument
148 if (list == NULL) in kmod_list_insert_before()
149 return kmod_list_append(list, data); in kmod_list_insert_before()
156 list_node_insert_before(&list->node, &new->node); in kmod_list_insert_before()
175 struct kmod_list *kmod_list_prepend(struct kmod_list *list, const void *data) in kmod_list_prepend() argument
184 list_node_append(list ? &list->node : NULL, &new->node); in kmod_list_prepend()
189 struct kmod_list *kmod_list_remove(struct kmod_list *list) in kmod_list_remove() argument
193 if (list == NULL) in kmod_list_remove()
196 node = list_node_remove(&list->node); in kmod_list_remove()
197 free(list); in kmod_list_remove()
205 struct kmod_list *kmod_list_remove_data(struct kmod_list *list, in kmod_list_remove_data() argument
211 for (itr = list; itr != NULL; itr = kmod_list_next(list, itr)) { in kmod_list_remove_data()
217 return list; in kmod_list_remove_data()
232 struct kmod_list *kmod_list_remove_n_latest(struct kmod_list *list, in kmod_list_remove_n_latest() argument
235 struct kmod_list *l = list; in kmod_list_remove_n_latest()
248 * @list: the head of the list
249 * @curr: the current node in the list
251 * Get the previous node in @list relative to @curr as if @list was not a
252 * circular list. I.e.: the previous of the head is NULL. It can be used to
253 * iterate a list by checking for NULL return to know when all elements were
257 * the list or the list is empty.
259 KMOD_EXPORT struct kmod_list *kmod_list_prev(const struct kmod_list *list, in kmod_list_prev() argument
262 if (list == NULL || curr == NULL) in kmod_list_prev()
265 if (list == curr) in kmod_list_prev()
273 * @list: the head of the list
274 * @curr: the current node in the list
276 * Get the next node in @list relative to @curr as if @list was not a circular
277 * list. I.e. calling this function in the last node of the list returns
278 * NULL.. It can be used to iterate a list by checking for NULL return to know
282 * list is empty.
284 KMOD_EXPORT struct kmod_list *kmod_list_next(const struct kmod_list *list, in kmod_list_next() argument
287 if (list == NULL || curr == NULL) in kmod_list_next()
290 if (curr->node.next == &list->node) in kmod_list_next()
298 * @list: the head of the list
300 * Get the last element of the @list. As @list is a circular list,
304 * If the list has a single element it will return the list itself (as
307 * Returns: last node at @list or NULL if the list is empty.
309 KMOD_EXPORT struct kmod_list *kmod_list_last(const struct kmod_list *list) in kmod_list_last() argument
311 if (list == NULL) in kmod_list_last()
313 return container_of(list->node.prev, struct kmod_list, node); in kmod_list_last()