aboutsummaryrefslogtreecommitdiffstats
path: root/src/classifiers
diff options
context:
space:
mode:
Diffstat (limited to 'src/classifiers')
-rw-r--r--src/classifiers/bayes.c10
-rw-r--r--src/classifiers/classifiers.h8
-rw-r--r--src/classifiers/winnow.c12
3 files changed, 15 insertions, 15 deletions
diff --git a/src/classifiers/bayes.c b/src/classifiers/bayes.c
index dfa4f768b..405336be7 100644
--- a/src/classifiers/bayes.c
+++ b/src/classifiers/bayes.c
@@ -190,9 +190,9 @@ bayes_classify_callback (gpointer key, gpointer value, gpointer data)
}
struct classifier_ctx*
-bayes_init (memory_pool_t *pool, struct classifier_config *cfg)
+bayes_init (rspamd_mempool_t *pool, struct classifier_config *cfg)
{
- struct classifier_ctx *ctx = memory_pool_alloc (pool, sizeof (struct classifier_ctx));
+ struct classifier_ctx *ctx = rspamd_mempool_alloc (pool, sizeof (struct classifier_ctx));
ctx->pool = pool;
ctx->cfg = cfg;
@@ -231,7 +231,7 @@ bayes_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input,
cur = call_classifier_pre_callbacks (ctx->cfg, task, FALSE, FALSE, L);
if (cur) {
- memory_pool_add_destructor (task->task_pool, (pool_destruct_func)g_list_free, cur);
+ rspamd_mempool_add_destructor (task->task_pool, (rspamd_mempool_destruct_t)g_list_free, cur);
}
else {
cur = ctx->cfg->statfiles;
@@ -296,7 +296,7 @@ bayes_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input,
if (data.processed_tokens > 0 && fabs (final_prob - 0.5) > 0.05) {
- sumbuf = memory_pool_alloc (task->task_pool, 32);
+ sumbuf = rspamd_mempool_alloc (task->task_pool, 32);
for (i = 0; i < cnt; i ++) {
if ((final_prob > 0.5 && !data.statfiles[i].st->is_spam) ||
(final_prob < 0.5 && data.statfiles[i].st->is_spam)) {
@@ -461,7 +461,7 @@ bayes_learn_spam (struct classifier_ctx* ctx, statfile_pool_t *pool,
cur = call_classifier_pre_callbacks (ctx->cfg, task, TRUE, is_spam, L);
if (cur) {
skip_labels = FALSE;
- memory_pool_add_destructor (task->task_pool, (pool_destruct_func)g_list_free, cur);
+ rspamd_mempool_add_destructor (task->task_pool, (rspamd_mempool_destruct_t)g_list_free, cur);
}
else {
/* Do not try to learn specific statfiles if pre callback returned nil */
diff --git a/src/classifiers/classifiers.h b/src/classifiers/classifiers.h
index fa9b60ad6..a316008cd 100644
--- a/src/classifiers/classifiers.h
+++ b/src/classifiers/classifiers.h
@@ -14,7 +14,7 @@ struct classifier_config;
struct worker_task;
struct classifier_ctx {
- memory_pool_t *pool;
+ rspamd_mempool_t *pool;
GHashTable *results;
gboolean debug;
struct classifier_config *cfg;
@@ -28,7 +28,7 @@ struct classify_weight {
/* Common classifier structure */
struct classifier {
char *name;
- struct classifier_ctx* (*init_func)(memory_pool_t *pool, struct classifier_config *cf);
+ struct classifier_ctx* (*init_func)(rspamd_mempool_t *pool, struct classifier_config *cf);
gboolean (*classify_func)(struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct worker_task *task, lua_State *L);
gboolean (*learn_func)(struct classifier_ctx* ctx, statfile_pool_t *pool,
const char *symbol, GTree *input, gboolean in_class,
@@ -42,7 +42,7 @@ struct classifier {
struct classifier* get_classifier (const char *name);
/* Winnow algorithm */
-struct classifier_ctx* winnow_init (memory_pool_t *pool, struct classifier_config *cf);
+struct classifier_ctx* winnow_init (rspamd_mempool_t *pool, struct classifier_config *cf);
gboolean winnow_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct worker_task *task, lua_State *L);
gboolean winnow_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, const char *symbol, GTree *input,
gboolean in_class, double *sum, double multiplier, GError **err);
@@ -51,7 +51,7 @@ gboolean winnow_learn_spam (struct classifier_ctx* ctx, statfile_pool_t *pool,
GList *winnow_weights (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct worker_task *task);
/* Bayes algorithm */
-struct classifier_ctx* bayes_init (memory_pool_t *pool, struct classifier_config *cf);
+struct classifier_ctx* bayes_init (rspamd_mempool_t *pool, struct classifier_config *cf);
gboolean bayes_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct worker_task *task, lua_State *L);
gboolean bayes_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, const char *symbol, GTree *input,
gboolean in_class, double *sum, double multiplier, GError **err);
diff --git a/src/classifiers/winnow.c b/src/classifiers/winnow.c
index 9568092b5..b9b5b7af9 100644
--- a/src/classifiers/winnow.c
+++ b/src/classifiers/winnow.c
@@ -182,9 +182,9 @@ winnow_learn_callback (gpointer key, gpointer value, gpointer data)
}
struct classifier_ctx *
-winnow_init (memory_pool_t * pool, struct classifier_config *cfg)
+winnow_init (rspamd_mempool_t * pool, struct classifier_config *cfg)
{
- struct classifier_ctx *ctx = memory_pool_alloc (pool, sizeof (struct classifier_ctx));
+ struct classifier_ctx *ctx = rspamd_mempool_alloc (pool, sizeof (struct classifier_ctx));
ctx->pool = pool;
ctx->cfg = cfg;
@@ -223,7 +223,7 @@ winnow_classify (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * inp
cur = call_classifier_pre_callbacks (ctx->cfg, task, FALSE, FALSE, L);
if (cur) {
- memory_pool_add_destructor (task->task_pool, (pool_destruct_func)g_list_free, cur);
+ rspamd_mempool_add_destructor (task->task_pool, (rspamd_mempool_destruct_t)g_list_free, cur);
}
else {
cur = ctx->cfg->statfiles;
@@ -272,7 +272,7 @@ winnow_classify (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * inp
*/
max = tanh ((double) max);
#endif
- sumbuf = memory_pool_alloc (task->task_pool, 32);
+ sumbuf = rspamd_mempool_alloc (task->task_pool, 32);
rspamd_snprintf (sumbuf, 32, "%.2F", max);
cur = g_list_prepend (NULL, sumbuf);
insert_result (task, sel->symbol, max, cur);
@@ -328,7 +328,7 @@ winnow_weights (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * inpu
g_tree_foreach (input, winnow_classify_callback, &data);
}
- w = memory_pool_alloc0 (task->task_pool, sizeof (struct classify_weight));
+ w = rspamd_mempool_alloc0 (task->task_pool, sizeof (struct classify_weight));
if (data.count != 0) {
res = data.sum / (double)data.count;
}
@@ -342,7 +342,7 @@ winnow_weights (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * inpu
}
if (resl != NULL) {
- memory_pool_add_destructor (task->task_pool, (pool_destruct_func)g_list_free, resl);
+ rspamd_mempool_add_destructor (task->task_pool, (rspamd_mempool_destruct_t)g_list_free, resl);
}
return resl;