From: Vsevolod Stakhov Date: Mon, 8 May 2023 17:43:36 +0000 (+0100) Subject: [Minor] Add utility to iterate over values by pointer and keys X-Git-Tag: 3.6~132 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=852a21d68ec2850f95b74a829639264ddf264f30;p=thirdparty%2Frspamd.git [Minor] Add utility to iterate over values by pointer and keys --- diff --git a/contrib/libucl/khash.h b/contrib/libucl/khash.h index 3e580011db..0b8a4356de 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) { \