aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-05-08 18:43:36 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-05-08 18:43:36 +0100
commit852a21d68ec2850f95b74a829639264ddf264f30 (patch)
tree57b4082d59df83ec5aa28d3012e51eda8475be89 /contrib
parent0618c0a2b2456fa4cf5dcb5a6a5478398bb5b2a1 (diff)
downloadrspamd-852a21d68ec2850f95b74a829639264ddf264f30.tar.gz
rspamd-852a21d68ec2850f95b74a829639264ddf264f30.zip
[Minor] Add utility to iterate over values by pointer and keys
Diffstat (limited to 'contrib')
-rw-r--r--contrib/libucl/khash.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/contrib/libucl/khash.h b/contrib/libucl/khash.h
index 3e580011d..0b8a4356d 100644
--- a/contrib/libucl/khash.h
+++ b/contrib/libucl/khash.h
@@ -583,6 +583,14 @@ static kh_inline khint_t __ac_Wang_hash(khint_t key)
code; \
} }
+#define kh_foreach_key_value_ptr(h, kvar, pvvar, code) { khint_t __i; \
+ for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \
+ if (!kh_exist(h,__i)) continue; \
+ (kvar) = kh_key(h,__i); \
+ (pvvar) = &kh_val(h,__i); \
+ code; \
+ } }
+
#define kh_foreach_key(h, kvar, code) { \
khint_t __i; \
for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \