From 20f19b78d042c6db9226ab0f2b7403cc0e49a070 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 26 Jul 2018 12:23:07 +0100 Subject: [PATCH] [Minor] Simplify hashes definitions --- src/libmime/filter.c | 1 + src/libmime/filter.h | 16 ++++------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/libmime/filter.c b/src/libmime/filter.c index 1c836e4a7..efdcb24a0 100644 --- a/src/libmime/filter.c +++ b/src/libmime/filter.c @@ -255,6 +255,7 @@ insert_metric_result (struct rspamd_task *task, sym_cpy = rspamd_mempool_strdup (task->task_pool, symbol); k = kh_put (rspamd_symbols_hash, metric_res->symbols, sym_cpy, &ret); + g_assert (ret > 0); s = &kh_value (metric_res->symbols, k); memset (s, 0, sizeof (*s)); diff --git a/src/libmime/filter.h b/src/libmime/filter.h index b6d7a4359..0b962e6aa 100644 --- a/src/libmime/filter.h +++ b/src/libmime/filter.h @@ -28,12 +28,8 @@ enum rspamd_symbol_result_flags { /** * Rspamd symbol */ -KHASH_INIT (rspamd_options_hash, - const char *, - struct rspamd_symbol_option *, - true, - rspamd_str_hash, - rspamd_str_equal); +KHASH_MAP_INIT_STR (rspamd_options_hash, struct rspamd_symbol_option *); + struct rspamd_symbol_result { double score; /**< symbol's score */ khash_t(rspamd_options_hash) *options; /**< list of symbol's options */ @@ -47,13 +43,9 @@ struct rspamd_symbol_result { /** * Result of metric processing */ -KHASH_INIT (rspamd_symbols_hash, - const char *, - struct rspamd_symbol_result, - true, - rspamd_str_hash, - rspamd_str_equal); +KHASH_MAP_INIT_STR (rspamd_symbols_hash, struct rspamd_symbol_result); KHASH_MAP_INIT_INT (rspamd_symbols_group_hash, double); + struct rspamd_metric_result { double score; /**< total score */ double grow_factor; /**< current grow factor */ -- 2.39.5