Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 30eab78 in mainline


Ignore:
Timestamp:
2017-06-27T17:14:57Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
39b0a51
Parents:
b76ce3f
Message:

Remove remaining differences between kernel and user lists.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/adt/list.c

    rb76ce3f r30eab78  
    6969
    7070/** Moves items of one list into another after the specified item.
    71  * 
    72  * Inserts all items of @a list after item at @a pos in another list. 
    73  * Both lists may be empty. 
    74  * 
     71 *
     72 * Inserts all items of @a list after item at @a pos in another list.
     73 * Both lists may be empty.
     74 *
    7575 * @param list Source list to move after pos. Empty afterwards.
    7676 * @param pos Source items will be placed after this item.
  • uspace/lib/c/generic/adt/list.c

    rb76ce3f r30eab78  
    6969}
    7070
    71 /** Concatenate two lists
     71/** Moves items of one list into another after the specified item.
    7272 *
    73  * Concatenate lists @a list1 and @a list2, producing a single
    74  * list @a list1 containing items from both (in @a list1, @a list2
    75  * order) and empty list @a list2.
     73 * Inserts all items of @a list after item at @a pos in another list.
     74 * Both lists may be empty.
    7675 *
    77  * @param list1         First list and concatenated output
    78  * @param list2         Second list and empty output.
    79  *
     76 * @param list Source list to move after pos. Empty afterwards.
     77 * @param pos Source items will be placed after this item.
    8078 */
    81 void list_concat(list_t *list1, list_t *list2)
     79void list_splice(list_t *list, link_t *pos)
    8280{
    83         if (list_empty(list2))
     81        if (list_empty(list))
    8482                return;
    85 
    86         list2->head.next->prev = list1->head.prev;
    87         list2->head.prev->next = &list1->head;
    88         list1->head.prev->next = list2->head.next;
    89         list1->head.prev = list2->head.prev;
    90         list_initialize(list2);
     83       
     84        /* Attach list to destination. */
     85        list->head.next->prev = pos;
     86        list->head.prev->next = pos->next;
     87       
     88        /* Link destination list to the added list. */
     89        pos->next->prev = list->head.prev;
     90        pos->next = list->head.next;
     91       
     92        list_initialize(list);
    9193}
    9294
  • uspace/lib/c/include/adt/list.h

    rb76ce3f r30eab78  
    5454
    5555extern bool list_member(const link_t *, const list_t *);
    56 extern void list_concat(list_t *, list_t *);
     56extern void list_splice(list_t *, link_t *);
    5757extern unsigned long list_count(const list_t *);
    5858
     
    351351}
    352352
     353/** Concatenate two lists
     354 *
     355 * Concatenate lists @a list1 and @a list2, producing a single
     356 * list @a list1 containing items from both (in @a list1, @a list2
     357 * order) and empty list @a list2.
     358 *
     359 * @param list1         First list and concatenated output
     360 * @param list2         Second list and empty output.
     361 *
     362 */
     363NO_TRACE static inline void list_concat(list_t *list1, list_t *list2)
     364{
     365        list_splice(list2, list1->head.prev);
     366}
     367
    353368/** Get n-th item in a list.
    354369 *
     
    399414}
    400415
    401 
    402416#endif
    403417
Note: See TracChangeset for help on using the changeset viewer.