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:
parent
28f42fcecc
commit
ed3f63ae37
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user