[PATCH 22/44] stringlist: implement string_list_empty

Ahmad Fatoum a.fatoum at barebox.org
Mon Aug 11 05:28:02 PDT 2025


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.fatoum at 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




More information about the barebox mailing list