projects
/
mesa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
94ff352
)
util: Add list_is_singular() helper function
author
Eduardo Lima Mitev
<elima@igalia.com>
Fri, 23 Oct 2015 14:31:41 +0000
(16:31 +0200)
committer
Eduardo Lima Mitev
<elima@igalia.com>
Tue, 10 Nov 2015 20:13:35 +0000
(21:13 +0100)
Returns whether the list has exactly one element.
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/util/list.h
patch
|
blob
|
history
diff --git
a/src/util/list.h
b/src/util/list.h
index b98ce59ff77d6c6344f6147fe13214b022c7a863..066f9b8dfe50bb5852e9b31d781e602cb6b55ce4 100644
(file)
--- a/
src/util/list.h
+++ b/
src/util/list.h
@@
-99,6
+99,14
@@
static inline bool list_empty(struct list_head *list)
return list->next == list;
}
+/**
+ * Returns whether the list has exactly one element.
+ */
+static inline bool list_is_singular(const struct list_head *list)
+{
+ return list->next != NULL && list->next->next == list;
+}
+
static inline unsigned list_length(struct list_head *list)
{
struct list_head *node;