diff mbox series

[v3,01/27] alist: add a helper to check if the list is full

Message ID 20240821105839.2870293-2-sughosh.ganu@linaro.org
State Superseded
Headers show
Series Make LMB memory map global and persistent | expand

Commit Message

Sughosh Ganu Aug. 21, 2024, 10:58 a.m. UTC
Add a helper function to check if the alist is full. This can then be
used to extend the alist.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
Changes since V2: None

 include/alist.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Simon Glass Aug. 23, 2024, 8:47 p.m. UTC | #1
Hi Sughosh,

On Wed, 21 Aug 2024 at 04:59, Sughosh Ganu <sughosh.ganu@linaro.org> wrote:
>
> Add a helper function to check if the alist is full. This can then be
> used to extend the alist.
>
> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> ---
> Changes since V2: None
>
>  include/alist.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

I would still rather add an alist_insert() function, but we can clean
that up later.

>
> diff --git a/include/alist.h b/include/alist.h
> index 586a1efa5c..68d268f01a 100644
> --- a/include/alist.h
> +++ b/include/alist.h
> @@ -82,6 +82,17 @@ 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_get_ptr() - Get the value of a pointer
>   *
> --
> 2.34.1
>

Regards,
Simon
diff mbox series

Patch

diff --git a/include/alist.h b/include/alist.h
index 586a1efa5c..68d268f01a 100644
--- a/include/alist.h
+++ b/include/alist.h
@@ -82,6 +82,17 @@  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_get_ptr() - Get the value of a pointer
  *