Fixed a stupid bug in list_move_to_list(): it did not work for empty lists.

The kernel no longer trashes memory when you delete a port without any
messages in its queue (i.e. you can now safely link against libbe.so :)).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8736 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2004-08-31 04:45:02 +00:00
parent 0ebb4701b9
commit 1980b54a21

View File

@ -198,10 +198,18 @@ list_remove_tail_item(struct list *list)
void
list_move_to_list(struct list *sourceList, struct list *targetList)
{
if (list_is_empty(sourceList)) {
targetList->link.next = targetList->link.prev = &targetList->link;
return;
}
*targetList = *sourceList;
// correct link pointers to this list
targetList->link.next->prev = &targetList->link;
targetList->link.prev->next = &targetList->link;
// empty source list
sourceList->link.next = sourceList->link.prev = &sourceList->link;
}