From 9c3d566e95c9080f6040c64531b0ccae22bd5d74 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sat, 15 Jan 2005 07:15:38 +0000 Subject: 2005-01-15 Havoc Pennington * Land the new message args API and type system. This patch is huge, but the public API change is not really large. The set of D-BUS types has changed somewhat, and the arg "getters" are more geared toward language bindings; they don't make a copy, etc. There are also some known issues. See these emails for details on this huge patch: http://lists.freedesktop.org/archives/dbus/2004-December/001836.html http://lists.freedesktop.org/archives/dbus/2005-January/001922.html * dbus/dbus-marshal-*: all the new stuff * dbus/dbus-message.c: basically rewritten * dbus/dbus-memory.c (check_guards): with "guards" enabled, init freed blocks to be all non-nul bytes so using freed memory is less likely to work right * dbus/dbus-internals.c (_dbus_test_oom_handling): add DBUS_FAIL_MALLOC=N environment variable, so you can do DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or DBUS_FAIL_MALLOC=10 to make it really, really, really slow and thorough. * qt/message.cpp: port to the new message args API (operator<<): use str.utf8() rather than str.unicode() (pretty sure this is right from the Qt docs?) * glib/dbus-gvalue.c: port to the new message args API * bus/dispatch.c, bus/driver.c: port to the new message args API * dbus/dbus-string.c (_dbus_string_init_const_len): initialize the "locked" flag to TRUE and align_offset to 0; I guess we never looked at these anyhow, but seems cleaner. * dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING): move allocation padding macro to this header; use it to implement (_DBUS_STRING_STATIC): ability to declare a static string. * dbus/dbus-message.c (_dbus_message_has_type_interface_member): change to return TRUE if the interface is not set. * dbus/dbus-string.[hc]: move the D-BUS specific validation stuff to dbus-marshal-validate.[hc] * dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from dbus-internals.c * dbus/Makefile.am: cut over from dbus-marshal.[hc] to dbus-marshal-*.[hc] * dbus/dbus-object-tree.c (_dbus_decompose_path): move this function here from dbus-marshal.c --- dbus/dbus-internals.c | 76 ++++++++++++++++++--------------------------------- 1 file changed, 26 insertions(+), 50 deletions(-) (limited to 'dbus/dbus-internals.c') diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index 6d2395fd..2aa26805 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -354,42 +354,6 @@ _dbus_string_array_contains (const char **array, return FALSE; } -/** - * Returns a string describing the given type. - * - * @param type the type to describe - * @returns a constant string describing the type - */ -const char * -_dbus_type_to_string (int type) -{ - switch (type) - { - case DBUS_TYPE_INVALID: - return "invalid"; - case DBUS_TYPE_NIL: - return "nil"; - case DBUS_TYPE_BOOLEAN: - return "boolean"; - case DBUS_TYPE_INT32: - return "int32"; - case DBUS_TYPE_UINT32: - return "uint32"; - case DBUS_TYPE_DOUBLE: - return "double"; - case DBUS_TYPE_STRING: - return "string"; - case DBUS_TYPE_CUSTOM: - return "custom"; - case DBUS_TYPE_ARRAY: - return "array"; - case DBUS_TYPE_DICT: - return "dict"; - default: - return "unknown"; - } -} - /** * Returns a string describing the given name. * @@ -525,6 +489,9 @@ _dbus_test_oom_handling (const char *description, void *data) { int approx_mallocs; + const char *setting; + int max_failures_to_try; + int i; /* Run once to see about how many mallocs are involved */ @@ -540,21 +507,30 @@ _dbus_test_oom_handling (const char *description, _dbus_verbose ("\n=================\n%s: about %d mallocs total\n=================\n", description, approx_mallocs); - _dbus_set_fail_alloc_failures (1); - if (!run_failing_each_malloc (approx_mallocs, description, func, data)) - return FALSE; - - _dbus_set_fail_alloc_failures (2); - if (!run_failing_each_malloc (approx_mallocs, description, func, data)) - return FALSE; - - _dbus_set_fail_alloc_failures (3); - if (!run_failing_each_malloc (approx_mallocs, description, func, data)) - return FALSE; + setting = _dbus_getenv ("DBUS_TEST_MALLOC_FAILURES"); + if (setting != NULL) + { + DBusString str; + long v; + _dbus_string_init_const (&str, setting); + v = 4; + if (!_dbus_string_parse_int (&str, 0, &v, NULL)) + _dbus_warn ("couldn't parse '%s' as integer\n", setting); + max_failures_to_try = v; + } + else + { + max_failures_to_try = 4; + } - _dbus_set_fail_alloc_failures (4); - if (!run_failing_each_malloc (approx_mallocs, description, func, data)) - return FALSE; + i = setting ? max_failures_to_try - 1 : 1; + while (i < max_failures_to_try) + { + _dbus_set_fail_alloc_failures (i); + if (!run_failing_each_malloc (approx_mallocs, description, func, data)) + return FALSE; + ++i; + } _dbus_verbose ("\n=================\n%s: all iterations passed\n=================\n", description); -- cgit