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>
diff --git a/lib/alist.c b/lib/alist.c
index 7730fe0..1a4b4fb 100644
--- a/lib/alist.c
+++ b/lib/alist.c
@@ -118,6 +118,13 @@
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);