diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-25 18:23:24 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-25 18:23:24 +0000 |
commit | 06d5e6c256a86af708933b2abef80370d50bec3d (patch) | |
tree | 0e9d4ed9879abafd299d28eb712950ec2f27cf16 /src | |
parent | 24a64389974df532beab7cb48e4280cde2c87cc0 (diff) | |
download | rspamd-06d5e6c256a86af708933b2abef80370d50bec3d.tar.gz rspamd-06d5e6c256a86af708933b2abef80370d50bec3d.zip |
Do not store zeroes in hash table.
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/task.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libserver/task.c b/src/libserver/task.c index 9ac66b65c..e7a2c18af 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -457,15 +457,17 @@ rspamd_task_re_cache_add (struct rspamd_task *task, const gchar *re, guint value) { guint ret = RSPAMD_TASK_CACHE_NO_VALUE; + static const guint32 mask = 1 << 31; gpointer p; p = g_hash_table_lookup (task->re_cache, re); if (p != NULL) { - ret = GPOINTER_TO_INT (p); + ret = GPOINTER_TO_INT (p) & ~mask; } - g_hash_table_insert (task->re_cache, (gpointer)re, GINT_TO_POINTER (value)); + g_hash_table_insert (task->re_cache, (gpointer)re, + GINT_TO_POINTER (value | mask)); return ret; } @@ -474,12 +476,13 @@ guint rspamd_task_re_cache_check (struct rspamd_task *task, const gchar *re) { guint ret = RSPAMD_TASK_CACHE_NO_VALUE; + static const guint32 mask = 1 << 31; gpointer p; p = g_hash_table_lookup (task->re_cache, re); if (p != NULL) { - ret = GPOINTER_TO_INT (p); + ret = GPOINTER_TO_INT (p) & ~mask; } return ret; |