summaryrefslogtreecommitdiff
path: root/kern/list.h
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2014-05-12 12:10:39 +0200
committerRichard Braun <rbraun@sceen.net>2014-05-12 14:05:27 +0200
commit5c27fcf62bfed84a398690127b206d0b41e788b5 (patch)
treed89b7fe029c4083b18c1557434a8041076da2975 /kern/list.h
parent2ca8c231bb3b509bb6eb90e2e2065079a78fbd1e (diff)
kern/list: fix splitting
Diffstat (limited to 'kern/list.h')
-rw-r--r--kern/list.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/kern/list.h b/kern/list.h
index fef0370b..29ecfcb4 100644
--- a/kern/list.h
+++ b/kern/list.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2010 Richard Braun.
+ * Copyright (c) 2009-2014 Richard Braun.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -157,16 +157,19 @@ list_singular(const struct list *list)
}
/*
- * Split list2 by moving its nodes up to (but not including) the given
- * node into list1 (which can be in a stale state).
+ * Split list2 by moving its nodes up to, but not including, the given
+ * node into list1, which can be in a stale state.
*
- * If list2 is empty, or node is list2 or list2->next, nothing is done.
+ * If list2 is empty, or node is list2 or list2->next, list1 is merely
+ * initialized.
*/
static inline void
list_split(struct list *list1, struct list *list2, struct list *node)
{
- if (list_empty(list2) || (list2->next == node) || list_end(list2, node))
+ if (list_empty(list2) || (list2->next == node) || list_end(list2, node)) {
+ list_init(list1);
return;
+ }
list1->next = list2->next;
list1->next->prev = list1;