Changeset 062d900 in mainline for uspace/lib/c/include/adt/list.h
- Timestamp:
- 2012-10-09T11:49:43Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4e00f87
- Parents:
- 87e9392
- git-author:
- Adam Hraska <adam.hraska+hos@…> (2012-10-09 11:49:43)
- git-committer:
- Jakub Jermar <jakub@…> (2012-10-09 11:49:43)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/adt/list.h
r87e9392 r062d900 71 71 iterator != &(list).head; iterator = iterator->next) 72 72 73 /** Unlike list_foreach(), allows removing items while traversing a list. 74 * 75 * @code 76 * list_t mylist; 77 * typedef struct item { 78 * int value; 79 * link_t item_link; 80 * } item_t; 81 * 82 * //.. 83 * 84 * // Print each list element's value and remove the element from the list. 85 * list_foreach_safe(mylist, cur_link, next_link) { 86 * item_t *cur_item = list_get_instance(cur_link, item_t, item_link); 87 * printf("%d\n", cur_item->value); 88 * list_remove(cur_link); 89 * } 90 * @endcode 91 * 92 * @param list List to traverse. 93 * @param iterator Iterator to the current element of the list. 94 * The item this iterator points may be safely removed 95 * from the list. 96 * @param next_iter Iterator to the next element of the list. 97 */ 98 #define list_foreach_safe(list, iterator, next_iter) \ 99 for (link_t *iterator = (list).head.next, \ 100 *next_iter = iterator->next; \ 101 iterator != &(list).head; \ 102 iterator = next_iter, next_iter = iterator->next) 103 73 104 #define assert_link_not_used(link) \ 74 105 assert(((link)->prev == NULL) && ((link)->next == NULL)) 106 107 /** Returns true if the link is definitely part of a list. False if not sure. */ 108 static inline int link_in_use(link_t *link) 109 { 110 return link->prev != NULL && link->next != NULL; 111 } 75 112 76 113 /** Initialize doubly-linked circular list link
Note:
See TracChangeset
for help on using the changeset viewer.