Changes in kernel/generic/include/adt/list.h [9d58539:c14762e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/adt/list.h
r9d58539 rc14762e 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 53 59 /** Declare and initialize statically allocated list. 54 60 * … … 71 77 iterator != &(list).head; iterator = iterator->next) 72 78 79 /** Unlike list_foreach(), allows removing items while traversing a list. 80 * 81 * @code 82 * 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 * @endcode 97 * 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 removed 101 * 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 73 111 #define assert_link_not_used(link) \ 74 112 ASSERT(((link)->prev == NULL) && ((link)->next == NULL)) … … 85 123 link->prev = NULL; 86 124 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; 87 136 } 88 137 … … 256 305 { 257 306 headless_list_split_or_concat(part1, part2); 307 } 308 309 /** Concatenate two lists 310 * 311 * Concatenate lists @a list1 and @a list2, producing a single 312 * list @a list1 containing items from both (in @a list1, @a list2 313 * order) and empty list @a list2. 314 * 315 * @param list1 First list and concatenated output 316 * @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); 258 322 } 259 323 … … 281 345 } 282 346 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 287 347 #endif 288 348
Note:
See TracChangeset
for help on using the changeset viewer.