Changes in kernel/generic/src/adt/list.c [1ab4aca:0a02653] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/adt/list.c
r1ab4aca r0a02653 33 33 /** 34 34 * @file 35 * @brief Functions completing doubly linked circular list implementa tion.35 * @brief Functions completing doubly linked circular list implementaion. 36 36 * 37 37 * This file contains some of the functions implementing doubly linked circular lists. … … 43 43 /** Check for membership 44 44 * 45 * Check whether link is contained in a list.46 * Membership is defined as pointer equivalence.45 * Check whether link is contained in the list head. 46 * The membership is defined as pointer equivalence. 47 47 * 48 * @param link 49 * @param listList to look in.48 * @param link Item to look for. 49 * @param head List to look in. 50 50 * 51 * @return true if link is contained in list, false otherwise.51 * @return true if link is contained in head, false otherwise. 52 52 * 53 53 */ 54 int list_member(const link_t *link, const li st_t *list)54 int list_member(const link_t *link, const link_t *head) 55 55 { 56 56 bool found = false; 57 link_t *hlp = list->head.next;57 link_t *hlp = head->next; 58 58 59 while (hlp != &list->head) {59 while (hlp != head) { 60 60 if (hlp == link) { 61 61 found = true; … … 68 68 } 69 69 70 70 71 /** Concatenate two lists 71 72 * 72 * Concatenate lists @a list1 and @a list2, producing a single73 * list @a list1 containing items from both (in @a list1, @a list274 * order) and empty list @a list2.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. 75 76 * 76 * @param list1First list and concatenated output77 * @param list2Second list and empty output.77 * @param head1 First list and concatenated output 78 * @param head2 Second list and empty output. 78 79 * 79 80 */ 80 void list_concat(li st_t *list1, list_t *list2)81 void list_concat(link_t *head1, link_t *head2) 81 82 { 82 if (list_empty( list2))83 if (list_empty(head2)) 83 84 return; 84 85 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); 90 } 91 92 /** Count list items 93 * 94 * Return the number of items in the list. 95 * 96 * @param list List to count. 97 * @return Number of items in the list. 98 */ 99 unsigned int list_count(const list_t *list) 100 { 101 unsigned int count = 0; 102 103 list_foreach(*list, link) { 104 count++; 105 } 106 107 return count; 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); 108 91 } 109 92
Note:
See TracChangeset
for help on using the changeset viewer.