summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-memory.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2005-01-15 07:15:38 +0000
committerHavoc Pennington <hp@redhat.com>2005-01-15 07:15:38 +0000
commit9c3d566e95c9080f6040c64531b0ccae22bd5d74 (patch)
treed21a18baa5a5ee9855c8a00eb2c1985bc23ca65f /dbus/dbus-memory.c
parent6ec04e917c8b4d477e818aa65ebb5e1fd50e4395 (diff)
2005-01-15 Havoc Pennington <hp@redhat.com>
* 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
Diffstat (limited to 'dbus/dbus-memory.c')
-rw-r--r--dbus/dbus-memory.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c
index 3b59c26f..b28c6b11 100644
--- a/dbus/dbus-memory.c
+++ b/dbus/dbus-memory.c
@@ -317,7 +317,8 @@ source_string (BlockSource source)
}
static void
-check_guards (void *free_block)
+check_guards (void *free_block,
+ dbus_bool_t overwrite)
{
if (free_block != NULL)
{
@@ -364,6 +365,10 @@ check_guards (void *free_block)
i += 4;
}
+ /* set memory to anything but nul bytes */
+ if (overwrite)
+ memset (free_block, 'g', requested_bytes);
+
if (failed)
_dbus_assert_not_reached ("guard value corruption");
}
@@ -401,7 +406,7 @@ set_guards (void *real_block,
i += 4;
}
- check_guards (block + GUARD_START_OFFSET);
+ check_guards (block + GUARD_START_OFFSET, FALSE);
return block + GUARD_START_OFFSET;
}
@@ -558,7 +563,7 @@ dbus_realloc (void *memory,
size_t old_bytes;
void *block;
- check_guards (memory);
+ check_guards (memory, FALSE);
block = realloc (((unsigned char*)memory) - GUARD_START_OFFSET,
bytes + GUARD_EXTRA_SIZE);
@@ -566,7 +571,7 @@ dbus_realloc (void *memory,
old_bytes = *(dbus_uint32_t*)block;
if (block && bytes >= old_bytes)
/* old guards shouldn't have moved */
- check_guards (((unsigned char*)block) + GUARD_START_OFFSET);
+ check_guards (((unsigned char*)block) + GUARD_START_OFFSET, FALSE);
return set_guards (block, bytes, SOURCE_REALLOC);
}
@@ -607,7 +612,7 @@ dbus_free (void *memory)
#ifdef DBUS_BUILD_TESTS
if (guards)
{
- check_guards (memory);
+ check_guards (memory, TRUE);
if (memory)
{
n_blocks_outstanding -= 1;