const gchar *loc)
RSPAMD_ATTR_ALLOC_SIZE(2) RSPAMD_ATTR_ALLOC_ALIGN(MIN_MEM_ALIGNMENT) RSPAMD_ATTR_RETURNS_NONNUL;
+
+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 (G_UNLIKELY (pool->priv->flags & RSPAMD_MEMPOOL_DEBUG)) {
+ ptr = g_hash_table_lookup (debug_tbl, loc);
+
+ if (ptr) {
+ ptr = GSIZE_TO_POINTER (GPOINTER_TO_SIZE (ptr) + size);
+ }
+ else {
+ ptr = GSIZE_TO_POINTER (size);
+ }
+
+ g_hash_table_insert (debug_tbl, (gpointer) loc, ptr);
+ }
+}
+
static void *
memory_pool_alloc_common (rspamd_mempool_t * pool, gsize size,
enum rspamd_mempool_chain_type pool_type, const gchar *loc)
pool->priv->used_memory += size;
if (G_UNLIKELY (pool->priv->flags & RSPAMD_MEMPOOL_DEBUG)) {
- GHashTable *debug_tbl = *(GHashTable **)(((guchar *)pool + sizeof (*pool)));
- gpointer ptr;
-
- ptr = g_hash_table_lookup (debug_tbl, loc);
-
- if (ptr) {
- ptr = GSIZE_TO_POINTER (GPOINTER_TO_SIZE (ptr) + size);
- }
- else {
- ptr = GSIZE_TO_POINTER (size);
- }
-
- g_hash_table_insert (debug_tbl, (gpointer)loc, ptr);
+ rspamd_mempool_notify_alloc_ (pool, size, loc);
}
if (always_malloc && pool_type != RSPAMD_MEMPOOL_SHARED) {
#define rspamd_mempool_alloc(pool, size) \
rspamd_mempool_alloc_((pool), (size), G_STRLOC)
+/**
+ * Notify external memory usage for memory pool
+ * @param pool
+ * @param size
+ * @param loc
+ */
+void rspamd_mempool_notify_alloc_ (rspamd_mempool_t *pool, gsize size, const gchar *loc);
+#define rspamd_mempool_notify_alloc(pool, size) \
+ rspamd_mempool_notify_alloc_((pool), (size), G_STRLOC)
+
/**
* Get memory and set it to zero
* @param pool memory pool object