Changeset 55b77d9 in mainline for kernel/generic/src/adt/list.c


Ignore:
Timestamp:
2011-06-17T20:39:16Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8f164724
Parents:
98caf49
Message:

Separate list_t typedef from link_t (kernel part).

  • list_t represents lists
  • Use list_first(), list_last(), list_empty() where appropriate
  • Use list_foreach() where possible
  • Replace improper uses of list_prepend() with list_insert_after()
  • Replace improper uses of list_append() with list_insert_before()
File:
1 edited

Legend:

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

    r98caf49 r55b77d9  
    4343/** Check for membership
    4444 *
    45  * Check whether link is contained in the list head.
    46  * The membership is defined as pointer equivalence.
     45 * Check whether link is contained in a list.
     46 * Membership is defined as pointer equivalence.
    4747 *
    48  * @param link Item to look for.
    49  * @param head List to look in.
     48 * @param link  Item to look for.
     49 * @param list  List to look in.
    5050 *
    5151 * @return true if link is contained in head, false otherwise.
    5252 *
    5353 */
    54 int list_member(const link_t *link, const link_t *head)
     54int list_member(const link_t *link, const list_t *list)
    5555{
    5656        bool found = false;
    57         link_t *hlp = head->next;
     57        link_t *hlp = list->head.next;
    5858       
    59         while (hlp != head) {
     59        while (hlp != &list->head) {
    6060                if (hlp == link) {
    6161                        found = true;
     
    6868}
    6969
    70 
    7170/** Concatenate two lists
    7271 *
    73  * Concatenate lists head1 and head2, producing a single
    74  * list head1 containing items from both (in head1, head2
    75  * order) and empty list head2.
     72 * Concatenate lists @a list1 and @a list2, producing a single
     73 * list @a list1 containing items from both (in @a list1, @a list2
     74 * order) and empty list @a list2.
    7675 *
    77  * @param head1 First list and concatenated output
    78  * @param head2 Second list and empty output.
     76 * @param list1         First list and concatenated output
     77 * @param list2         Second list and empty output.
    7978 *
    8079 */
    81 void list_concat(link_t *head1, link_t *head2)
     80void list_concat(list_t *list1, list_t *list2)
    8281{
    83         if (list_empty(head2))
     82        if (list_empty(list2))
    8483                return;
    8584
    86         head2->next->prev = head1->prev;
    87         head2->prev->next = head1;     
    88         head1->prev->next = head2->next;
    89         head1->prev = head2->prev;
    90         list_initialize(head2);
     85        list2->head.next->prev = list1->head.prev;
     86        list2->head.prev->next = &list1->head;
     87        list1->head.prev->next = list2->head.next;
     88        list1->head.prev = list2->head.prev;
     89        list_initialize(list2);
    9190}
    9291
Note: See TracChangeset for help on using the changeset viewer.