Mesa (master): util/list: Add list splicing functions
Jason Ekstrand
jekstrand at kemper.freedesktop.org
Fri Apr 15 20:31:15 UTC 2016
Module: Mesa
Branch: master
Commit: 7dac4a2889673c52bded63e2daef360e9e927eb3
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7dac4a2889673c52bded63e2daef360e9e927eb3
Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date: Thu Jul 30 11:28:22 2015 -0700
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 <mark.a.janes at intel.com>
Reviewed-by: Rob Clark <robclark at freedesktop.org>
---
src/util/list.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/util/list.h b/src/util/list.h
index 066f9b8..f0dec5d 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;
More information about the mesa-commit
mailing list