[PATCH 06/40] alist: add a couple of helper functions
Sughosh Ganu
sughosh.ganu at linaro.org
Wed Jul 24 08:01:50 CEST 2024
Add a couple of helper functions to detect an empty and full alist.
Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
---
Changes since rfc: None
include/alist.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/include/alist.h b/include/alist.h
index 6cc3161dcd..06ae137102 100644
--- a/include/alist.h
+++ b/include/alist.h
@@ -82,6 +82,28 @@ static inline bool alist_err(struct alist *lst)
return lst->flags & ALISTF_FAIL;
}
+/**
+ * alist_full() - Check if the alist is full
+ *
+ * @lst: List to check
+ * Return: true if full, false otherwise
+ */
+static inline bool alist_full(struct alist *lst)
+{
+ return lst->count == lst->alloc;
+}
+
+/**
+ * alist_empty() - Check if the alist is empty
+ *
+ * @lst: List to check
+ * Return: true if empty, false otherwise
+ */
+static inline bool alist_empty(struct alist *lst)
+{
+ return !lst->count && lst->alloc;
+}
+
/**
* alist_get_ptr() - Get the value of a pointer
*
--
2.34.1
More information about the U-Boot
mailing list