diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-01-29 15:03:08 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-01-29 15:03:08 +0000 |
commit | 971025ceca5af31e11a1d079302365bb6f3d7f8c (patch) | |
tree | da5707f0ec99f965b22ae0adabfdf28f69da5bba /src/libmime/scan_result_private.h | |
parent | 3f7e7ef47f25974950e1ecf114a3430d11b63b9a (diff) | |
download | rspamd-971025ceca5af31e11a1d079302365bb6f3d7f8c.tar.gz rspamd-971025ceca5af31e11a1d079302365bb6f3d7f8c.zip |
[Rework] Rework options hash structure
Diffstat (limited to 'src/libmime/scan_result_private.h')
-rw-r--r-- | src/libmime/scan_result_private.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/libmime/scan_result_private.h b/src/libmime/scan_result_private.h index aa90430e1..cb4ff4cda 100644 --- a/src/libmime/scan_result_private.h +++ b/src/libmime/scan_result_private.h @@ -12,7 +12,23 @@ extern "C" { #endif -KHASH_MAP_INIT_STR (rspamd_options_hash, struct rspamd_symbol_option *); +#define RSPAMD_OPTS_SEED 0x9f1f608628a4fefbULL +#define rspamd_symopt_hash(opt) (rspamd_cryptobox_fast_hash ( \ + ((struct rspamd_symbol_option *)opt)->option, \ + ((struct rspamd_symbol_option *)opt)->optlen, RSPAMD_OPTS_SEED)) +static inline bool +rspamd_symopt_equal (const struct rspamd_symbol_option *o1, + const struct rspamd_symbol_option *o2) +{ + if (o1->optlen == o2->optlen) { + return (memcmp (o1->option, o2->option, o1->optlen) == 0); + } + + return false; +} + +KHASH_INIT (rspamd_options_hash, struct rspamd_symbol_option *, char, + 0, rspamd_symopt_hash, rspamd_symopt_equal); /** * Result of metric processing */ |