#include <config.h>
#include "dbus-mempool.h"
#include "dbus-internals.h"
+#include "dbus-valgrind-internal.h"
/**
* @defgroup DBusMemPool memory pools
_dbus_assert ((pool->block_size %
pool->element_size) == 0);
-
+
+ VALGRIND_CREATE_MEMPOOL (pool, 0, zero_elements)
+
return pool;
}
{
DBusMemBlock *block;
+ VALGRIND_DESTROY_MEMPOOL (pool)
+
block = pool->blocks;
while (block != NULL)
{
pool->blocks = block;
pool->allocated_elements += 1;
+ VALGRIND_MEMPOOL_ALLOC (pool, (void *) &block->elements[0],
+ pool->element_size)
return (void*) &block->elements[0];
}
else
pool->free_elements = pool->free_elements->next;
+ VALGRIND_MEMPOOL_ALLOC (pool, element, pool->element_size)
+
if (pool->zero_elements)
memset (element, '\0', pool->element_size);
pool->allocated_elements += 1;
-
+
return element;
}
else
pool->blocks->used_so_far += pool->element_size;
pool->allocated_elements += 1;
-
+
+ VALGRIND_MEMPOOL_ALLOC (pool, element, pool->element_size)
return element;
}
}
_dbus_mem_pool_dealloc (DBusMemPool *pool,
void *element)
{
+ VALGRIND_MEMPOOL_FREE (pool, element)
+
#ifdef DBUS_BUILD_TESTS
if (_dbus_disable_mem_pools ())
{
DBusFreedElement *freed;
freed = element;
+ /* used for internal mempool administration */
+ VALGRIND_MAKE_MEM_UNDEFINED (freed, sizeof (freed));
+
freed->next = pool->free_elements;
pool->free_elements = freed;