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:
@@ -198,10 +198,18 @@ list_remove_tail_item(struct list *list)
|
|||||||
void
|
void
|
||||||
list_move_to_list(struct list *sourceList, struct list *targetList)
|
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;
|
*targetList = *sourceList;
|
||||||
|
|
||||||
|
// correct link pointers to this list
|
||||||
targetList->link.next->prev = &targetList->link;
|
targetList->link.next->prev = &targetList->link;
|
||||||
targetList->link.prev->next = &targetList->link;
|
targetList->link.prev->next = &targetList->link;
|
||||||
|
|
||||||
|
// empty source list
|
||||||
sourceList->link.next = sourceList->link.prev = &sourceList->link;
|
sourceList->link.next = sourceList->link.prev = &sourceList->link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user