[Mesa-dev] [PATCH 10/13] util/list: Add a list validation function

Jason Ekstrand jason at jlekstrand.net
Mon Apr 27 21:03:45 PDT 2015


---
 src/util/list.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/util/list.h b/src/util/list.h
index 246f826..f11b858 100644
--- a/src/util/list.h
+++ b/src/util/list.h
@@ -105,6 +105,13 @@ static inline unsigned list_length(struct list_head *list)
    return length;
 }
 
+static inline void list_validate(struct list_head *list)
+{
+   assert(list->next->prev == list && list->prev->next == list);
+   for (struct list_head *node = list->next; node != list; node = node->next)
+      assert(node->next->prev == node && node->prev->next == node);
+}
+
 #define LIST_INITHEAD(__item) list_inithead(__item)
 #define LIST_ADD(__item, __list) list_add(__item, __list)
 #define LIST_ADDTAIL(__item, __list) list_addtail(__item, __list)
-- 
2.3.6



More information about the mesa-dev mailing list