We already have string_list_count, but it needs to walk fully the linked
list, even if we are only interested in knowing if the list is empty or
not. Add a helper for this situation.

Signed-off-by: Ahmad Fatoum <a.fat...@barebox.org>
---
 include/stringlist.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/stringlist.h b/include/stringlist.h
index 03711ad9c7ff..9a982f2ad685 100644
--- a/include/stringlist.h
+++ b/include/stringlist.h
@@ -26,6 +26,11 @@ static inline void string_list_init(struct string_list *sl)
        sl->str = NULL;
 }
 
+static inline size_t string_list_empty(struct string_list *sl)
+{
+       return list_empty(&sl->list);
+}
+
 static inline size_t string_list_count(struct string_list *sl)
 {
        return list_count_nodes(&sl->list);
-- 
2.39.5


Reply via email to