summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass <[email protected]>2024-10-19 09:21:45 -0600
committerSimon Glass <[email protected]>2024-11-02 11:13:59 -0600
commit83bc5989fc5f71e2c40d75ea786ccbf937b9fbab (patch)
tree0b298b79b2413d877ef2091499e1b6723654716c /lib
parent2ce146a3de7beeaa89ef4f8677fe71a38546156b (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 <[email protected]>
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);