[Mesa-dev] [PATCH] util/list: Add list splicing functions

Jason Ekstrand jason at jlekstrand.net
Fri Apr 15 01:25:57 UTC 2016


This adds functions for splicing one list into another.  These have
more-or-less the same API as the kernel list splicing functions.
---
 src/util/list.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/util/list.h b/src/util/list.h
index b98ce59..d4b4851 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;
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list