summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2024-10-19 09:21:45 -0600
committerTom Rini <trini@konsulko.com>2024-11-03 21:27:12 -0600
commitd785a77d18acdf6714f4570c14e622caadf4d5e3 (patch)
treef56b11412024f9d23d7d2e97f7da5e4430fa9290 /lib
parent1d49f78c362981435a88d887c777ccc445f5a4e7 (diff)
alist: Add for-loop helpers
Add some macros which permit easy iteration through an alist, similar to those provided by the 'list' implementation. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/alist.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/alist.c b/lib/alist.c
index 7730fe0d473..1a4b4fb9c40 100644
--- a/lib/alist.c
+++ b/lib/alist.c
@@ -118,6 +118,13 @@ int alist_calc_index(const struct alist *lst, const void *ptr)
return index;
}
+bool alist_chk_ptr(const struct alist *lst, const void *ptr)
+{
+ int index = alist_calc_index(lst, ptr);
+
+ return index >= 0 && index < lst->count;
+}
+
const void *alist_next_ptrd(const struct alist *lst, const void *ptr)
{
int index = alist_calc_index(lst, ptr);