summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-internals.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-08-07 02:18:54 +0000
committerHavoc Pennington <hp@redhat.com>2003-08-07 02:18:54 +0000
commitcefb84edc5f84011c5a171e5d052e37c56c55d27 (patch)
tree1857fc269db9094f012f819e20d02adcd267c059 /dbus/dbus-internals.c
parentff8908f1e98eda82b0a77abb449ecff36abf14aa (diff)
2003-08-06 Havoc Pennington <hp@pobox.com>
* dbus/dbus-object-registry.c: implement signal connection and dispatch * dbus/dbus-connection.c (_dbus_connection_unref_unlocked): new * dbus/dbus-internals.c (_dbus_memdup): new function
Diffstat (limited to 'dbus/dbus-internals.c')
-rw-r--r--dbus/dbus-internals.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c
index 6e7f9e16..ccc11776 100644
--- a/dbus/dbus-internals.c
+++ b/dbus/dbus-internals.c
@@ -248,7 +248,7 @@ _dbus_verbose_reset_real (void)
char*
_dbus_strdup (const char *str)
{
- int len;
+ size_t len;
char *copy;
if (str == NULL)
@@ -265,6 +265,31 @@ _dbus_strdup (const char *str)
return copy;
}
+#ifdef DBUS_BUILD_TESTS /* memdup not used at the moment */
+/**
+ * Duplicates a block of memory. Returns
+ * #NULL on failure.
+ *
+ * @param mem memory to copy
+ * @param n_bytes number of bytes to copy
+ * @returns the copy
+ */
+void*
+_dbus_memdup (const void *mem,
+ size_t n_bytes)
+{
+ void *copy;
+
+ copy = dbus_malloc (n_bytes);
+ if (copy == NULL)
+ return NULL;
+
+ memcpy (copy, mem, n_bytes);
+
+ return copy;
+}
+#endif
+
/**
* Duplicates a string array. Result may be freed with
* dbus_free_string_array(). Returns #NULL if memory allocation fails.