diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-04 19:38:42 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-04 19:38:42 -0600 |
commit | 4f7cf6b416ccede492ace64533ab35a9a289f463 (patch) | |
tree | db28d138f8b6d4c9bf71f2790881ea04f68b3ece /lib9p/map.h | |
parent | 860a9e995b8e7076ce4e5c231e844184bef9b95e (diff) |
wip
Diffstat (limited to 'lib9p/map.h')
-rw-r--r-- | lib9p/map.h | 3 |
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 |