Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/adt/list.h

    rc14762e r9d58539  
    5151} list_t;
    5252
    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 
    5953/** Declare and initialize statically allocated list.
    6054 *
     
    7771            iterator != &(list).head; iterator = iterator->next)
    7872
    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        
    11173#define assert_link_not_used(link) \
    11274        ASSERT(((link)->prev == NULL) && ((link)->next == NULL))
     
    12385        link->prev = NULL;
    12486        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;
    13687}
    13788
     
    305256{
    306257        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);
    322258}
    323259
     
    345281}
    346282
     283extern int list_member(const link_t *, const list_t *);
     284extern void list_concat(list_t *, list_t *);
     285extern unsigned int list_count(const list_t *);
     286
    347287#endif
    348288
Note: See TracChangeset for help on using the changeset viewer.