void*
_dbus_mem_pool_alloc (DBusMemPool *pool)
{
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
if (_dbus_disable_mem_pools ())
{
DBusMemBlock *block;
/* Need a new block */
DBusMemBlock *block;
int alloc_size;
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
int saved_counter;
#endif
alloc_size = sizeof (DBusMemBlock) - ELEMENT_PADDING + pool->block_size;
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
/* We save/restore the counter, so that memory pools won't
* cause a given function to have different number of
* allocations on different invocations. i.e. when testing
else
block = dbus_malloc (alloc_size);
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
_dbus_set_fail_alloc_counter (saved_counter);
_dbus_assert (saved_counter == _dbus_get_fail_alloc_counter ());
#endif
{
VALGRIND_MEMPOOL_FREE (pool, element);
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
if (_dbus_disable_mem_pools ())
{
DBusMemBlock *block;
freed = element;
/* used for internal mempool administration */
- VALGRIND_MAKE_MEM_UNDEFINED (freed, sizeof (freed));
+ VALGRIND_MAKE_MEM_UNDEFINED (freed, sizeof (*freed));
freed->next = pool->free_elements;
pool->free_elements = freed;
/** @} */
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
#include "dbus-test.h"
#include <stdio.h>
#include <time.h>
{
int i;
int j;
+#ifdef DBUS_ENABLE_VERBOSE_MODE
clock_t start;
clock_t end;
+#endif
#define FREE_ARRAY_SIZE 512
#define N_ITERATIONS FREE_ARRAY_SIZE * 512
void *to_free[FREE_ARRAY_SIZE];
_dbus_verbose (" malloc\n");
+#ifdef DBUS_ENABLE_VERBOSE_MODE
start = clock ();
-
+#endif
+
i = 0;
j = 0;
while (i < N_ITERATIONS)
++i;
}
+#ifdef DBUS_ENABLE_VERBOSE_MODE
end = clock ();
_dbus_verbose (" created/destroyed %d elements in %g seconds\n",
_dbus_verbose (" mempools\n");
start = clock ();
+#endif
pool = _dbus_mem_pool_new (size, FALSE);
_dbus_mem_pool_free (pool);
+#ifdef DBUS_ENABLE_VERBOSE_MODE
end = clock ();
_dbus_verbose (" created/destroyed %d elements in %g seconds\n",
_dbus_verbose (" zeroed malloc\n");
start = clock ();
+#endif
i = 0;
j = 0;
++i;
}
+#ifdef DBUS_ENABLE_VERBOSE_MODE
end = clock ();
_dbus_verbose (" created/destroyed %d elements in %g seconds\n",
_dbus_verbose (" zeroed mempools\n");
start = clock ();
+#endif
pool = _dbus_mem_pool_new (size, TRUE);
_dbus_mem_pool_free (pool);
+#ifdef DBUS_ENABLE_VERBOSE_MODE
end = clock ();
_dbus_verbose (" created/destroyed %d elements in %g seconds\n",
N_ITERATIONS, (end - start) / (double) CLOCKS_PER_SEC);
+#endif
}
/**
return TRUE;
}
-#endif /* DBUS_BUILD_TESTS */
+#endif /* DBUS_ENABLE_EMBEDDED_TESTS */