summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEduardo Lima Mitev <elima@igalia.com>2015-10-23 16:31:41 +0200
committerEduardo Lima Mitev <elima@igalia.com>2015-11-10 21:13:35 +0100
commitfb3b5669cee85781b603f612228387e9a2e4120f (patch)
tree8492a7f852f6680384ef38d19cfbee78df7f71d0 /src
parent94ff35204dba0ddbd7f5c4342206c8acba22d32f (diff)
downloadexternal_mesa3d-fb3b5669cee85781b603f612228387e9a2e4120f.zip
external_mesa3d-fb3b5669cee85781b603f612228387e9a2e4120f.tar.gz
external_mesa3d-fb3b5669cee85781b603f612228387e9a2e4120f.tar.bz2
util: Add list_is_singular() helper function
Returns whether the list has exactly one element. Reviewed-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/util/list.h8
1 files changed, 8 insertions, 0 deletions
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;