summaryrefslogtreecommitdiff
path: root/lib9p/map.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/map.h')
-rw-r--r--lib9p/map.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib9p/map.h b/lib9p/map.h
index 9df9be7..ea9cdb6 100644
--- a/lib9p/map.h
+++ b/lib9p/map.h
@@ -27,6 +27,9 @@
#ifndef MAP_KEY
#define MAP_KV(TNAME) CAT3(_,TNAME,_kv)
#define MAP_METHOD(TNAME, MNAME) CAT3(TNAME,_,MNAME)
+#define MAP_FOREACH(m, k, v) \
+ for (size_t i = 0, typeof(m->items[0].key) k, typeof(&m->items[0].val) v; i < ARRAY_LEN(m->items); i++) \
+ if ( ({ k = m->items[i].key; v = &m->items[i].val; m->items[i].set; }) )
#endif
/* This implementation is just an array that we brute-force search