summaryrefslogtreecommitdiffstats
path: root/src/util/list.h
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-07-30 11:28:22 -0700
committerJason Ekstrand <[email protected]>2016-04-15 13:29:09 -0700
commit7dac4a2889673c52bded63e2daef360e9e927eb3 (patch)
treec8cd58288f54935b1349a37947f7c9c5ab9a6ff5 /src/util/list.h
parent082f6d75aef4e672b6e41ee77630d3add7e1ef5d (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. The implementation, however, was stolen from the Wayland list implementation. Reviewed-by: Mark Janes <[email protected]> Reviewed-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/util/list.h')
-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 066f9b8dfe5..f0dec5da608 100644
--- a/src/util/list.h
+++ b/src/util/list.h
@@ -116,6 +116,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;