#endif
struct mempool_chunk {
+#ifdef CONFIG_DEBUG
+ struct mempool *pool; // Can be useful when analysing coredump for memory leaks
+#endif
struct mempool_chunk *next;
size_t size;
};
ASAN_UNPOISON_MEMORY_REGION(pool, sizeof(*pool));
DBG("Creating mempool %p with %zu bytes long chunks", pool, chunk_size);
chunk->next = NULL;
+#ifdef CONFIG_DEBUG
+ chunk->pool = pool;
+#endif
ASAN_POISON_MEMORY_REGION(chunk, sizeof(struct mempool_chunk));
*pool = (struct mempool) {
.state = { .free = { chunk_size - sizeof(*pool) }, .last = { chunk } },
pool->unused = chunk->next;
} else {
chunk = mp_new_chunk(pool->chunk_size);
+#ifdef CONFIG_DEBUG
+ chunk->pool = pool;
+#endif
}
chunk->next = pool->state.last[0];
ASAN_POISON_MEMORY_REGION(chunk, sizeof(struct mempool_chunk));
return NULL;
}
chunk->next = pool->state.last[1];
+#ifdef CONFIG_DEBUG
+ chunk->pool = pool;
+#endif
+
ASAN_POISON_MEMORY_REGION(chunk, sizeof(struct mempool_chunk));
pool->state.last[1] = chunk;
pool->state.free[1] = aligned - size;