mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-04 04:50:11 +01:00
util/list: Add a list validation function
Acked-by: Connor Abbott <cwabbott0@gmail.com> Reviewed-by: Rob Clark <robclark@freedesktop.org>
This commit is contained in:
parent
addcf41066
commit
2c2cd368aa
1 changed files with 9 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue