Mesa (master): util/list: Add a list validation function
Jason Ekstrand
jekstrand at kemper.freedesktop.org
Sat May 9 00:29:59 UTC 2015
Module: Mesa
Branch: master
Commit: 2c2cd368aad9167816547aa86009c9cb489255c0
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c2cd368aad9167816547aa86009c9cb489255c0
Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date: Mon Apr 27 20:40:11 2015 -0700
util/list: Add a list validation function
Acked-by: Connor Abbott <cwabbott0 at gmail.com>
Reviewed-by: Rob Clark <robclark at freedesktop.org>
---
src/util/list.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/util/list.h b/src/util/list.h
index 73b6272..9460347 100644
--- a/src/util/list.h
+++ b/src/util/list.h
@@ -40,6 +40,7 @@
#include <stdbool.h>
#include <stddef.h>
+#include <assert.h>
struct list_head
@@ -107,6 +108,14 @@ static inline unsigned list_length(struct list_head *list)
return length;
}
+static inline void list_validate(struct list_head *list)
+{
+ struct list_head *node;
+ assert(list->next->prev == list && list->prev->next == list);
+ for (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)
More information about the mesa-commit
mailing list