Added a call to move the contents of one list to another.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6957 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2004-03-12 21:34:20 +00:00
parent 28f42fcecc
commit ed3f63ae37
2 changed files with 18 additions and 0 deletions

View File

@ -52,6 +52,7 @@ extern void list_add_item(struct list *list, void *item);
extern void list_remove_item(struct list *list, void *item);
extern void *list_remove_head_item(struct list *list);
extern void *list_remove_tail_item(struct list *list);
extern void *list_move_to_list(struct list *sourceList, struct list *targetList);
static inline bool
list_is_empty(struct list *list)

View File

@ -189,3 +189,20 @@ list_remove_tail_item(struct list *list)
return GET_ITEM(list, link);
}
/** Moves the contents of the source list to the target list.
* The target list will be emptied before the items are moved;
* this is a very fast operation.
*/
void *
list_move_to_list(struct list *sourceList, struct list *targetList)
{
*targetList = *sourceList;
targetList->link.next->prev = &targetList->link;
targetList->link.prev->next = &targetList->link;
sourceList->link.next = sourceList->link.prev = &sourceList->link;
}