From: Eduardo Lima Mitev Date: Fri, 23 Oct 2015 14:31:41 +0000 (+0200) Subject: util: Add list_is_singular() helper function X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fb3b5669cee85781b603f612228387e9a2e4120f;p=mesa.git util: Add list_is_singular() helper function Returns whether the list has exactly one element. Reviewed-by: Matt Turner --- diff --git a/src/util/list.h b/src/util/list.h index b98ce59ff77..066f9b8dfe5 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;