aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-08-26 15:31:37 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-08-26 15:31:37 +0400
commit2930bc26cb03546e9be2e38948adfdb2d623b7dd (patch)
tree2be1415d572b293131c15dbe8f24aa1b3f93842f /src
parente9606fd020e0b25be7ed9fade46a90a6454f3e3d (diff)
downloadrspamd-2930bc26cb03546e9be2e38948adfdb2d623b7dd.tar.gz
rspamd-2930bc26cb03546e9be2e38948adfdb2d623b7dd.zip
* Fix integer division
Diffstat (limited to 'src')
-rw-r--r--src/symbols_cache.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/symbols_cache.c b/src/symbols_cache.c
index d1aec71de..1d5d38d4d 100644
--- a/src/symbols_cache.c
+++ b/src/symbols_cache.c
@@ -42,7 +42,8 @@
#define MIN_CACHE 17
-uint64_t total_frequency;
+static uint64_t total_frequency;
+static uint32_t nsymbols;
int
cache_cmp (const void *p1, const void *p2)
@@ -57,11 +58,11 @@ cache_logic_cmp (const void *p1, const void *p2)
{
const struct cache_item *i1 = p1, *i2 = p2;
double w1, w2;
- int f1 = 0, f2 = 0;
+ double f1 = 0, f2 = 0;
if (total_frequency > 0) {
- f1 = i1->s->frequency / total_frequency;
- f2 = i2->s->frequency / total_frequency;
+ f1 = ((double)i1->s->frequency * nsymbols) / (double)total_frequency;
+ f2 = ((double)i2->s->frequency * nsymbols) / (double)total_frequency;
}
w1 = abs (i1->s->weight) * WEIGHT_MULT +
f1 * FREQUENCY_MULT +
@@ -115,6 +116,7 @@ post_cache_init (struct symbols_cache *cache)
int i;
total_frequency = 0;
+ nsymbols = cache->used_items;
for (i = 0; i < cache->used_items; i ++) {
total_frequency += cache->items[i].s->frequency;
}