diff mbox series

[RFC,v2,05/48] alist: add a couple of helper functions

Message ID 20240704073544.670249-6-sughosh.ganu@linaro.org
State Superseded
Headers show
Series Make U-Boot memory reservations coherent | expand

Commit Message

Sughosh Ganu July 4, 2024, 7:35 a.m. UTC
Add a couple of helper functions to detect an empty and full alist.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
Changes since V1: New patch

 include/alist.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
diff mbox series

Patch

diff --git a/include/alist.h b/include/alist.h
index a68afc9fff..bab146c35d 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
  *