summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-04-27 20:40:11 -0700
committerJason Ekstrand <[email protected]>2015-05-08 17:16:13 -0700
commit2c2cd368aad9167816547aa86009c9cb489255c0 (patch)
tree93beb721176d834d39dc77737ca8b4cf9ccb036a /src
parentaddcf41066d28a5d2d5ed112a65a3958b056bd19 (diff)
util/list: Add a list validation function
Acked-by: Connor Abbott <[email protected]> Reviewed-by: Rob Clark <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/util/list.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/util/list.h b/src/util/list.h
index 73b6272ca19..946034710ef 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)