From 56edd66ae3e8661d40d499bd7c72f3ffc7aac4e7 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sat, 22 Mar 2025 16:04:58 +0200 Subject: fix map iteration --- include/conts/map.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/conts/map.h b/include/conts/map.h index 5ffdff1..0d30897 100644 --- a/include/conts/map.h +++ b/include/conts/map.h @@ -197,14 +197,14 @@ static inline struct MAP_TUPLE *MAP(find_next)(struct MAP_BUCKET *bucket, struct { struct MAP_NODE *node = CONTAINER_OF(tuple, struct MAP_NODE, t); size_t idx = node - bucket->nodes; - for (idx += 1; idx < bucket->size; ++idx) { + for (; idx < bucket->size; ++idx) { struct MAP_NODE *candidate = &bucket->nodes[idx]; if (candidate->bucket) return &candidate->t; } struct MAP_BUCKET *next = bucket->next; - if (next) + if (!next) return NULL; return MAP(find_next)(next, &next->nodes[0].t); @@ -222,7 +222,7 @@ static inline struct MAP_TUPLE *MAP(begin)(struct MAP_ROOT *root) static inline struct MAP_TUPLE *MAP(next)(struct MAP_TUPLE *t) { struct MAP_NODE *node = CONTAINER_OF(t, struct MAP_NODE, t); - return MAP(find_next)(node->bucket, t); + return MAP(find_next)(node->bucket, &(node + 1)->t); } static inline bool MAP(end)(struct MAP_ROOT *root, struct MAP_TUPLE *t) -- cgit v1.2.3