From 91ad95911c0f67770829ce6bc90c70e66d01c868 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 4 Mar 2011 14:18:06 +0000 Subject: [PATCH 2/4] Add a configure option to disable the DBusMemPool for linked-list links --- cmake/CMakeLists.txt | 1 + cmake/config.h.cmake | 1 + configure.ac | 9 +++++++++ dbus/dbus-list.c | 12 ++++++++++-- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index b789eae..b9b75f2 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -95,6 +95,7 @@ endif(NOT WIN32) OPTION(DBUS_DISABLE_ASSERTS "Disable assertion checking" OFF) OPTION(DBUS_ENABLE_MESSAGE_CACHE "Enable a global message cache" ON) +OPTION(DBUS_ENABLE_LINK_POOL "Enable a grow-only memory pool for linked lists" ON) # do config checks INCLUDE(ConfigureChecks.cmake) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index b945c3d..fbc5f5b 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -52,6 +52,7 @@ #cmakedefine DBUS_DISABLE_ASSERTS 1 #cmakedefine DBUS_DISABLE_CHECKS 1 #cmakedefine DBUS_ENABLE_MESSAGE_CACHE 1 +#cmakedefine DBUS_ENABLE_LINK_POOL 1 /* xmldocs */ /* doxygen */ diff --git a/configure.ac b/configure.ac index f07b607..395740c 100644 --- a/configure.ac +++ b/configure.ac @@ -1631,6 +1631,15 @@ if test "x$enable_message_cache" = xyes; then [Define to use a global DBusMessage cache]) fi +AC_ARG_ENABLE([link-pool], + [AS_HELP_STRING([--disable-link-pool], + [disable the grow-only memory pool for linked lists])], + [], [enable_link_pool=yes]) +if test "x$enable_link_pool" = xyes; then + AC_DEFINE([DBUS_ENABLE_LINK_POOL], [1], + [Define to use a grow-only memory pool for linked lists (default)]) +fi + AC_CONFIG_FILES([ Doxyfile dbus/versioninfo.rc diff --git a/dbus/dbus-list.c b/dbus/dbus-list.c index 6a16ed6..20815f8 100644 --- a/dbus/dbus-list.c +++ b/dbus/dbus-list.c @@ -56,6 +56,7 @@ alloc_link (void *data) { DBusList *link; +#ifdef DBUS_ENABLE_LINK_POOL _DBUS_LOCK (list); if (list_pool == NULL) @@ -82,10 +83,13 @@ alloc_link (void *data) link = _dbus_mem_pool_alloc (list_pool); } + _DBUS_UNLOCK (list); +#else + link = dbus_malloc0 (sizeof (DBusList)); +#endif + if (link) link->data = data; - - _DBUS_UNLOCK (list); return link; } @@ -93,6 +97,7 @@ alloc_link (void *data) static void free_link (DBusList *link) { +#ifdef DBUS_ENABLE_LINK_POOL _DBUS_LOCK (list); if (_dbus_mem_pool_dealloc (list_pool, link)) { @@ -101,6 +106,9 @@ free_link (DBusList *link) } _DBUS_UNLOCK (list); +#else + dbus_free (link); +#endif } static void -- 1.7.4.1