struct regexp_ctx {
struct module_ctx ctx;
- rspamd_mempool_t *regexp_pool;
gsize max_size;
};
regexp_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
{
if (regexp_module_ctx == NULL) {
- regexp_module_ctx = g_malloc (sizeof (struct regexp_ctx));
- regexp_module_ctx->regexp_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL);
+ regexp_module_ctx = g_malloc0 (sizeof (struct regexp_ctx));
}
*ctx = (struct module_ctx *)regexp_module_ctx;
msg_warn_config ("regexp module is now single threaded, max_threads is ignored");
}
else if (value->type == UCL_STRING) {
- cur_item = rspamd_mempool_alloc0 (regexp_module_ctx->regexp_pool,
+ cur_item = rspamd_mempool_alloc0 (cfg->cfg_pool,
sizeof (struct regexp_module_item));
cur_item->symbol = ucl_object_key (value);
cur_item->magic = rspamd_regexp_cb_magic;
- if (!read_regexp_expression (regexp_module_ctx->regexp_pool,
+ if (!read_regexp_expression (cfg->cfg_pool,
cur_item, ucl_object_key (value),
ucl_obj_tostring (value), cfg)) {
res = FALSE;
}
else if (value->type == UCL_USERDATA) {
/* Just a lua function */
- cur_item = rspamd_mempool_alloc0 (regexp_module_ctx->regexp_pool,
+ cur_item = rspamd_mempool_alloc0 (cfg->cfg_pool,
sizeof (struct regexp_module_item));
cur_item->magic = rspamd_regexp_cb_magic;
cur_item->symbol = ucl_object_key (value);
elt = ucl_object_lookup_any (value, "regexp", "re", NULL);
if (elt != NULL && ucl_object_type (elt) == UCL_STRING) {
- cur_item = rspamd_mempool_alloc0 (regexp_module_ctx->regexp_pool,
+ cur_item = rspamd_mempool_alloc0 (cfg->cfg_pool,
sizeof (struct regexp_module_item));
cur_item->symbol = ucl_object_key (value);
cur_item->magic = rspamd_regexp_cb_magic;
- if (!read_regexp_expression (regexp_module_ctx->regexp_pool,
+ if (!read_regexp_expression (cfg->cfg_pool,
cur_item, ucl_object_key (value),
ucl_obj_tostring (elt), cfg)) {
res = FALSE;
is_lua = TRUE;
nlua ++;
cur_item = rspamd_mempool_alloc0 (
- regexp_module_ctx->regexp_pool,
+ cfg->cfg_pool,
sizeof (struct regexp_module_item));
cur_item->magic = rspamd_regexp_cb_magic;
cur_item->symbol = ucl_object_key (value);
struct module_ctx saved_ctx;
saved_ctx = regexp_module_ctx->ctx;
- rspamd_mempool_delete (regexp_module_ctx->regexp_pool);
memset (regexp_module_ctx, 0, sizeof (*regexp_module_ctx));
regexp_module_ctx->ctx = saved_ctx;
- regexp_module_ctx->regexp_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL);
return regexp_module_config (cfg);
}