diff options
Diffstat (limited to 'src/common/container.h')
-rw-r--r-- | src/common/container.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/common/container.h b/src/common/container.h index 3b5d72b1c2..305dc0ea0a 100644 --- a/src/common/container.h +++ b/src/common/container.h @@ -220,10 +220,33 @@ DECLARE_MAP_FNS(digestmap_t, const char *, digestmap_); prefix##iter_get(key##_iter, &keyvar, &valvar##_voidp); \ valvar = valvar##_voidp; +#define MAP_FOREACH_MODIFY(prefix, map, keytype, keyvar, valtype, valvar) \ + STMT_BEGIN \ + prefix##iter_t *key##_iter; \ + int keyvar##_del=0; \ + for (key##_iter = prefix##iter_init(map); \ + !prefix##iter_done(key##_iter); \ + key##_iter = keyvar##_del ? \ + prefix##iter_next_rmv(map, key##_iter) : \ + prefix##iter_next(map, key##_iter)) { \ + keytype keyvar; \ + void *valvar##_voidp; \ + valtype valvar; \ + keyvar##_del=0; \ + prefix##iter_get(key##_iter, &keyvar, &valvar##_voidp); \ + valvar = valvar##_voidp; + +#define MAP_DEL_CURRENT(keyvar) \ + STMT_BEGIN \ + keyvar##_del = 1; \ + STMT_END + #define MAP_FOREACH_END } STMT_END ; #define DIGESTMAP_FOREACH(map, keyvar, valtype, valvar) \ MAP_FOREACH(digestmap_, map, const char *, keyvar, valtype, valvar) +#define DIGESTMAP_FOREACH_MODIFY(map, keyvar, valtype, valvar) \ + MAP_FOREACH_MODIFY(digestmap_, map, const char *, keyvar, valtype, valvar) #define DIGESTMAP_FOREACH_END MAP_FOREACH_END void* strmap_set_lc(strmap_t *map, const char *key, void *val); |