guint nlen;
elt = g_malloc0 (sizeof (*elt));
+ rspamd_mempool_notify_alloc (pool, sizeof (*elt));
if (addr != NULL) {
memcpy (elt, addr, sizeof (*addr));
/* We need to unquote addr */
nlen = elt->domain_len + elt->user_len + 2;
elt->addr = g_malloc (nlen + 1);
+ rspamd_mempool_notify_alloc (pool, nlen + 1);
elt->addr_len = rspamd_snprintf ((char *)elt->addr, nlen, "%*s@%*s",
(gint)elt->user_len, elt->user,
(gint)elt->domain_len, elt->domain);
elt->name = rspamd_mime_header_decode (pool, name->str, name->len, NULL);
}
+ rspamd_mempool_notify_alloc (pool, name->len);
g_ptr_array_add (ar, elt);
}
break;
}
+ rspamd_mempool_notify_alloc (pool, cpy->len);
g_string_free (ns, TRUE);
return res;
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t) free_byte_array_callback,
part->utf_stripped_content);
+ rspamd_mempool_notify_alloc (task->task_pool,
+ part->utf_stripped_content->len);
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t) rspamd_ptr_array_free_hard,
part->newlines);
part_content = g_byte_array_sized_new (text_part->parsed.len);
memcpy (part_content->data, text_part->parsed.begin, text_part->parsed.len);
part_content->len = text_part->parsed.len;
+ rspamd_mempool_notify_alloc (task->task_pool,
+ part_content->len);
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t)g_byte_array_unref, part_content);
g_byte_array_free (token, TRUE);
g_byte_array_free (decoded, TRUE);
rspamd_mime_header_sanity_check (out);
+ rspamd_mempool_notify_alloc (pool, out->len);
ret = g_string_free (out, FALSE);
rspamd_mempool_add_destructor (pool, g_free, ret);
memcpy (parsed->str, part->raw_data.begin, parsed->len);
part->parsed_data.begin = parsed->str;
part->parsed_data.len = parsed->len;
+ rspamd_mempool_notify_alloc (task->task_pool, parsed->len);
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t)rspamd_fstring_free, parsed);
}
parsed->len = r;
part->parsed_data.begin = parsed->str;
part->parsed_data.len = parsed->len;
+ rspamd_mempool_notify_alloc (task->task_pool, parsed->len);
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t)rspamd_fstring_free, parsed);
}
parsed->len = part->raw_data.len;
part->parsed_data.begin = parsed->str;
part->parsed_data.len = parsed->len;
+ rspamd_mempool_notify_alloc (task->task_pool, parsed->len);
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t)rspamd_fstring_free, parsed);
}
parsed->str, &parsed->len);
part->parsed_data.begin = parsed->str;
part->parsed_data.len = parsed->len;
+ rspamd_mempool_notify_alloc (task->task_pool, parsed->len);
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t)rspamd_fstring_free, parsed);
break;
parsed = rspamd_fstring_sized_new (part->raw_data.len / 4 * 3 + 12);
r = rspamd_decode_uue_buf (part->raw_data.begin, part->raw_data.len,
parsed->str, parsed->allocated);
+ rspamd_mempool_notify_alloc (task->task_pool, parsed->len);
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t)rspamd_fstring_free, parsed);
if (r != -1) {
part->cte = RSPAMD_CTE_8BIT;
parsed->len = MIN (part->raw_data.len, parsed->allocated);
memcpy (parsed->str, part->raw_data.begin, parsed->len);
+ rspamd_mempool_notify_alloc (task->task_pool, parsed->len);
part->parsed_data.begin = parsed->str;
part->parsed_data.len = parsed->len;
}
if (hc->images == NULL) {
hc->images = g_ptr_array_sized_new (4);
+ rspamd_mempool_notify_alloc (pool, 4 * sizeof (gpointer) + sizeof (GPtrArray));
rspamd_mempool_add_destructor (pool, rspamd_ptr_array_free_hard,
hc->images);
}
if (hc->blocks == NULL) {
hc->blocks = g_ptr_array_sized_new (64);
+ rspamd_mempool_notify_alloc (pool, 64 * sizeof (gpointer) + sizeof (GPtrArray));
rspamd_mempool_add_destructor (pool, rspamd_ptr_array_free_hard,
hc->blocks);
}
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t)rspamd_fstring_free,
symbuf);
+ rspamd_mempool_notify_alloc (task->task_pool, symbuf->len);
res.begin = symbuf->str;
res.len = symbuf->len;
break;
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t) rspamd_fstring_free,
symbuf);
+ rspamd_mempool_notify_alloc (task->task_pool, symbuf->len);
res.begin = symbuf->str;
res.len = symbuf->len;
break;
task->tokens = g_ptr_array_sized_new (reserved_len);
rspamd_mempool_add_destructor (task->task_pool,
rspamd_ptr_array_free_hard, task->tokens);
+ rspamd_mempool_notify_alloc (task->task_pool, reserved_len * sizeof (gpointer));
pdiff = rspamd_mempool_get_variable (task->task_pool, "parts_distance");
PTR_ARRAY_FOREACH (MESSAGE_FIELD (task, text_parts), i, part) {
void
rspamd_mempool_notify_alloc_ (rspamd_mempool_t *pool, gsize size, const gchar *loc)
{
- GHashTable *debug_tbl = *(GHashTable **)(((guchar *)pool + sizeof (*pool)));
- gpointer ptr;
+ if (pool && G_UNLIKELY (pool->priv->flags & RSPAMD_MEMPOOL_DEBUG)) {
+ GHashTable *debug_tbl = *(GHashTable **)(((guchar *)pool + sizeof (*pool)));
+ gpointer ptr;
- if (G_UNLIKELY (pool->priv->flags & RSPAMD_MEMPOOL_DEBUG)) {
ptr = g_hash_table_lookup (debug_tbl, loc);
if (ptr) {