Changes in kernel/generic/include/adt/list.h [c14762e:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/adt/list.h
rc14762e r9d58539 51 51 } list_t; 52 52 53 54 extern int list_member(const link_t *, const list_t *);55 extern void list_splice(list_t *, link_t *);56 extern unsigned int list_count(const list_t *);57 58 59 53 /** Declare and initialize statically allocated list. 60 54 * … … 77 71 iterator != &(list).head; iterator = iterator->next) 78 72 79 /** Unlike list_foreach(), allows removing items while traversing a list.80 *81 * @code82 * list_t mylist;83 * typedef struct item {84 * int value;85 * link_t item_link;86 * } item_t;87 *88 * //..89 *90 * // Print each list element's value and remove the element from the list.91 * list_foreach_safe(mylist, cur_link, next_link) {92 * item_t *cur_item = list_get_instance(cur_link, item_t, item_link);93 * printf("%d\n", cur_item->value);94 * list_remove(cur_link);95 * }96 * @endcode97 *98 * @param list List to traverse.99 * @param iterator Iterator to the current element of the list.100 * The item this iterator points may be safely removed101 * from the list.102 * @param next_iter Iterator to the next element of the list.103 */104 #define list_foreach_safe(list, iterator, next_iter) \105 for (link_t *iterator = (list).head.next, \106 *next_iter = iterator->next; \107 iterator != &(list).head; \108 iterator = next_iter, next_iter = iterator->next)109 110 111 73 #define assert_link_not_used(link) \ 112 74 ASSERT(((link)->prev == NULL) && ((link)->next == NULL)) … … 123 85 link->prev = NULL; 124 86 link->next = NULL; 125 }126 127 /** Returns true if the initialized link is already in use by any list.128 *129 * @param link Link to examine whether if belongs to a list or not.130 * @return 1 if the link is part of a list.131 * @return 0 otherwise.132 */133 NO_TRACE static inline int link_used(const link_t *link)134 {135 return link->prev != NULL || link->next != NULL;136 87 } 137 88 … … 305 256 { 306 257 headless_list_split_or_concat(part1, part2); 307 }308 309 /** Concatenate two lists310 *311 * Concatenate lists @a list1 and @a list2, producing a single312 * list @a list1 containing items from both (in @a list1, @a list2313 * order) and empty list @a list2.314 *315 * @param list1 First list and concatenated output316 * @param list2 Second list and empty output.317 *318 */319 NO_TRACE static inline void list_concat(list_t *list1, list_t *list2)320 {321 list_splice(list2, list1->head.prev);322 258 } 323 259 … … 345 281 } 346 282 283 extern int list_member(const link_t *, const list_t *); 284 extern void list_concat(list_t *, list_t *); 285 extern unsigned int list_count(const list_t *); 286 347 287 #endif 348 288
Note:
See TracChangeset
for help on using the changeset viewer.