summaryrefslogtreecommitdiffstats
path: root/src/util/list.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/list.h')
-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;