]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add utility to iterate over values by pointer and keys
authorVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 8 May 2023 17:43:36 +0000 (18:43 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 8 May 2023 17:43:36 +0000 (18:43 +0100)
contrib/libucl/khash.h

index 3e580011dbd6b78da0ad73d30096fd3fb9480347..0b8a4356de4ea36f504230a44c5e58dc52c7da4b 100644 (file)
@@ -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) {              \