Mesa (master): util: Add list_is_singular() helper function
Eduardo Lima Mitev
elima at kemper.freedesktop.org
Tue Nov 10 20:59:14 UTC 2015
Module: Mesa
Branch: master
Commit: fb3b5669cee85781b603f612228387e9a2e4120f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fb3b5669cee85781b603f612228387e9a2e4120f
Author: Eduardo Lima Mitev <elima at igalia.com>
Date: Fri Oct 23 16:31:41 2015 +0200
util: Add list_is_singular() helper function
Returns whether the list has exactly one element.
Reviewed-by: Matt Turner <mattst88 at gmail.com>
---
src/util/list.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/util/list.h b/src/util/list.h
index b98ce59..066f9b8 100644
--- 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;
More information about the mesa-commit
mailing list