summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-07-30 11:28:22 -0700
committerJason Ekstrand <[email protected]>2015-07-30 11:28:22 -0700
commitf15be18c9210bfecd5d00819ed9edcdb4a667ffc (patch)
treecf3e588f1a02d5c59880d3130ca975edff8445db /src/util
parente39d0b635c3d6fdce81496ca859b0bdd9de68724 (diff)
util/list: Add list splicing functions
This adds functions for splicing one list into another. These have more-or-less the same API as the kernel list splicing functions.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/list.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/util/list.h b/src/util/list.h
index b98ce59ff77..d4b485174fc 100644
--- a/src/util/list.h
+++ b/src/util/list.h
@@ -108,6 +108,28 @@ static inline unsigned list_length(struct list_head *list)
return length;
}
+static inline void list_splice(struct list_head *src, struct list_head *dst)
+{
+ if (list_empty(src))
+ return;
+
+ src->next->prev = dst;
+ src->prev->next = dst->next;
+ dst->next->prev = src->prev;
+ dst->next = src->next;
+}
+
+static inline void list_splicetail(struct list_head *src, struct list_head *dst)
+{
+ if (list_empty(src))
+ return;
+
+ src->prev->next = dst;
+ src->next->prev = dst->prev;
+ dst->prev->next = src->next;
+ dst->prev = src->prev;
+}
+
static inline void list_validate(struct list_head *list)
{
struct list_head *node;