diff options
Diffstat (limited to 'dbus/dbus-list.c')
-rw-r--r-- | dbus/dbus-list.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/dbus/dbus-list.c b/dbus/dbus-list.c index 7e11cc8d..c4c1856f 100644 --- a/dbus/dbus-list.c +++ b/dbus/dbus-list.c @@ -35,8 +35,8 @@ * Types and functions related to DBusList. */ +/* Protected by _DBUS_LOCK (list) */ static DBusMemPool *list_pool; -_DBUS_DEFINE_GLOBAL_LOCK (list); /** * @defgroup DBusListInternals Linked list implementation details @@ -56,7 +56,8 @@ alloc_link (void *data) { DBusList *link; - _DBUS_LOCK (list); + if (!_DBUS_LOCK (list)) + return FALSE; if (list_pool == NULL) { @@ -93,7 +94,10 @@ alloc_link (void *data) static void free_link (DBusList *link) { - _DBUS_LOCK (list); + if (!_DBUS_LOCK (list)) + _dbus_assert_not_reached ("we should have initialized global locks " + "before we allocated a linked-list link"); + if (_dbus_mem_pool_dealloc (list_pool, link)) { _dbus_mem_pool_free (list_pool); @@ -152,7 +156,14 @@ _dbus_list_get_stats (dbus_uint32_t *in_use_p, dbus_uint32_t *in_free_list_p, dbus_uint32_t *allocated_p) { - _DBUS_LOCK (list); + if (!_DBUS_LOCK (list)) + { + *in_use_p = 0; + *in_free_list_p = 0; + *allocated_p = 0; + return; + } + _dbus_mem_pool_get_stats (list_pool, in_use_p, in_free_list_p, allocated_p); _DBUS_UNLOCK (list); } @@ -777,7 +788,7 @@ _dbus_list_length_is_one (DBusList **list) /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include <stdio.h> |