[glib/gdbus-merge] Plug some mem leaks
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/gdbus-merge] Plug some mem leaks
- Date: Thu, 13 May 2010 20:59:26 +0000 (UTC)
commit 4ad4c306c3b80620185cf975b402e17a6174aea9
Author: Christian Persch <chpe gnome org>
Date: Thu May 13 19:20:26 2010 +0200
Plug some mem leaks
g_variant_get (v, "s", &str) returns a string copy; use "&s" instead.
Signed-off-by: David Zeuthen <davidz redhat com>
gio/gdbus-tool.c | 20 ++++++++++----------
gio/gdbusconnection.c | 22 ++++++++++------------
gio/gdbusmessage.c | 2 +-
gio/gdbusnameowning.c | 4 ++--
gio/gdbusnamewatching.c | 4 ++--
gio/gdbusproxy.c | 4 ++--
6 files changed, 27 insertions(+), 29 deletions(-)
---
diff --git a/gio/gdbus-tool.c b/gio/gdbus-tool.c
index 5780c26..5b54893 100644
--- a/gio/gdbus-tool.c
+++ b/gio/gdbus-tool.c
@@ -167,7 +167,7 @@ print_methods (GDBusConnection *c,
g_variant_unref (result);
goto out;
}
- g_variant_get (result, "(s)", &xml_data);
+ g_variant_get (result, "(&s)", &xml_data);
error = NULL;
node = g_dbus_node_info_new_for_xml (xml_data, &error);
@@ -229,7 +229,9 @@ print_paths (GDBusConnection *c,
g_variant_unref (result);
goto out;
}
- g_variant_get (result, "(s)", &xml_data);
+ g_variant_get (result, "(&s)", &xml_data);
+
+ //g_printerr ("xml=`%s'", xml_data);
error = NULL;
node = g_dbus_node_info_new_for_xml (xml_data, &error);
@@ -241,8 +243,6 @@ print_paths (GDBusConnection *c,
goto out;
}
- //g_printerr ("xml=`%s'", xml_data);
-
//g_printerr ("bar `%s'\n", path);
if (node->interfaces != NULL)
@@ -308,7 +308,7 @@ print_names (GDBusConnection *c,
}
g_variant_get (result, "(as)", &iter);
while (g_variant_iter_loop (iter, "s", &str))
- g_hash_table_insert (name_set, g_strdup (str), NULL);
+ g_hash_table_insert (name_set, str, NULL);
g_variant_iter_free (iter);
g_variant_unref (result);
@@ -337,7 +337,7 @@ print_names (GDBusConnection *c,
}
g_variant_get (result, "(as)", &iter);
while (g_variant_iter_loop (iter, "s", &str))
- g_hash_table_insert (name_set, g_strdup (str), NULL);
+ g_hash_table_insert (name_set, str, NULL);
g_variant_iter_free (iter);
g_variant_unref (result);
@@ -476,7 +476,7 @@ call_helper_get_method_in_signature (GDBusConnection *c,
goto out;
}
- g_variant_get (result, "(s)", &xml_data);
+ g_variant_get (result, "(&s)", &xml_data);
node_info = g_dbus_node_info_new_for_xml (xml_data, error);
if (node_info == NULL)
goto out;
@@ -1071,14 +1071,14 @@ dump_interface (GDBusConnection *c,
&iter);
while ((item = g_variant_iter_next_value (iter)))
{
- const gchar *key;
+ gchar *key;
GVariant *value;
g_variant_get (item,
"{sv}",
&key,
&value);
- g_hash_table_insert (properties, g_strdup (key), g_variant_ref (value));
+ g_hash_table_insert (properties, key, g_variant_ref (value));
}
}
g_variant_unref (result);
@@ -1354,7 +1354,7 @@ handle_introspect (gint *argc,
g_variant_get_type_string (result));
goto out;
}
- g_variant_get (result, "(s)", &xml_data);
+ g_variant_get (result, "(&s)", &xml_data);
error = NULL;
node = g_dbus_node_info_new_for_xml (xml_data, &error);
diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c
index b02f1d6..d9c1615 100644
--- a/gio/gdbusconnection.c
+++ b/gio/gdbusconnection.c
@@ -1839,7 +1839,6 @@ initable_init (GInitable *initable,
if (connection->priv->flags & G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION)
{
GVariant *hello_result;
- const gchar *s;
hello_result = g_dbus_connection_call_sync (connection,
"org.freedesktop.DBus", /* name */
@@ -1854,8 +1853,7 @@ initable_init (GInitable *initable,
if (hello_result == NULL)
goto out;
- g_variant_get (hello_result, "(s)", &s);
- connection->priv->bus_unique_name = g_strdup (s);
+ g_variant_get (hello_result, "(s)", &connection->priv->bus_unique_name);
g_variant_unref (hello_result);
//g_debug ("unique name is `%s'", connection->priv->bus_unique_name);
}
@@ -3217,12 +3215,12 @@ validate_and_maybe_schedule_property_getset (GDBusConnection *connect
if (is_get)
g_variant_get (g_dbus_message_get_body (message),
- "(ss)",
+ "(&s&s)",
&interface_name,
&property_name);
else
g_variant_get (g_dbus_message_get_body (message),
- "(ssv)",
+ "(&s&sv)",
&interface_name,
&property_name,
NULL);
@@ -3321,12 +3319,12 @@ handle_getset_property (GDBusConnection *connection,
if (is_get)
g_variant_get (g_dbus_message_get_body (message),
- "(ss)",
+ "(&s&s)",
&interface_name,
&property_name);
else
g_variant_get (g_dbus_message_get_body (message),
- "(ssv)",
+ "(&s&sv)",
&interface_name,
&property_name,
NULL);
@@ -3456,7 +3454,7 @@ validate_and_maybe_schedule_property_get_all (GDBusConnection *connec
handled = FALSE;
g_variant_get (g_dbus_message_get_body (message),
- "(s)",
+ "(&s)",
&interface_name);
if (vtable == NULL || vtable->get_property == NULL)
@@ -3498,7 +3496,7 @@ handle_get_all_properties (GDBusConnection *connection,
handled = FALSE;
g_variant_get (g_dbus_message_get_body (message),
- "(s)",
+ "(&s)",
&interface_name);
/* Fail with org.freedesktop.DBus.Error.InvalidArgs if there is
@@ -4651,11 +4649,11 @@ handle_subtree_method_invocation (GDBusConnection *connection,
else if (is_property_get || is_property_set || is_property_get_all)
{
if (is_property_get)
- g_variant_get (g_dbus_message_get_body (message), "(ss)", &interface_name, NULL);
+ g_variant_get (g_dbus_message_get_body (message), "(&s&s)", &interface_name, NULL);
else if (is_property_set)
- g_variant_get (g_dbus_message_get_body (message), "(ssv)", &interface_name, NULL, NULL);
+ g_variant_get (g_dbus_message_get_body (message), "(&s&sv)", &interface_name, NULL, NULL);
else if (is_property_get_all)
- g_variant_get (g_dbus_message_get_body (message), "(s)", &interface_name, NULL, NULL);
+ g_variant_get (g_dbus_message_get_body (message), "(&s)", &interface_name, NULL, NULL);
else
g_assert_not_reached ();
diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c
index 9f871de..1fc3c09 100644
--- a/gio/gdbusmessage.c
+++ b/gio/gdbusmessage.c
@@ -2247,7 +2247,7 @@ g_dbus_message_to_gerror (GDBusMessage *message,
if (body != NULL && g_variant_is_of_type (body, G_VARIANT_TYPE ("(s)")))
{
const gchar *error_message;
- g_variant_get (body, "(s)", &error_message);
+ g_variant_get (body, "(&s)", &error_message);
g_dbus_error_set_dbus_error (error,
error_name,
error_message,
diff --git a/gio/gdbusnameowning.c b/gio/gdbusnameowning.c
index 90c0e84..ead9a5f 100644
--- a/gio/gdbusnameowning.c
+++ b/gio/gdbusnameowning.c
@@ -261,7 +261,7 @@ on_name_lost_or_acquired (GDBusConnection *connection,
if (g_strcmp0 (signal_name, "NameLost") == 0)
{
- g_variant_get (parameters, "(s)", &name);
+ g_variant_get (parameters, "(&s)", &name);
if (g_strcmp0 (name, client->name) == 0)
{
call_lost_handler (client);
@@ -269,7 +269,7 @@ on_name_lost_or_acquired (GDBusConnection *connection,
}
else if (g_strcmp0 (signal_name, "NameAcquired") == 0)
{
- g_variant_get (parameters, "(s)", &name);
+ g_variant_get (parameters, "(&s)", &name);
if (g_strcmp0 (name, client->name) == 0)
{
call_acquired_handler (client);
diff --git a/gio/gdbusnamewatching.c b/gio/gdbusnamewatching.c
index 903e444..f93a2ce 100644
--- a/gio/gdbusnamewatching.c
+++ b/gio/gdbusnamewatching.c
@@ -289,7 +289,7 @@ on_name_owner_changed (GDBusConnection *connection,
goto out;
g_variant_get (parameters,
- "(sss)",
+ "(&s&s&s)",
&name,
&old_owner,
&new_owner);
@@ -336,7 +336,7 @@ get_name_owner_cb (GObject *source_object,
NULL);
if (result != NULL)
{
- g_variant_get (result, "(s)", &name_owner);
+ g_variant_get (result, "(&s)", &name_owner);
}
if (name_owner != NULL)
diff --git a/gio/gdbusproxy.c b/gio/gdbusproxy.c
index 17619a1..b068710 100644
--- a/gio/gdbusproxy.c
+++ b/gio/gdbusproxy.c
@@ -848,7 +848,7 @@ process_get_all_reply (GDBusProxy *proxy,
g_variant_iter_init (&iter, g_variant_get_child_value (result, 0));
while ((item = g_variant_iter_next_value (&iter)) != NULL)
{
- const gchar *key;
+ gchar *key;
GVariant *value;
g_variant_get (item,
@@ -858,7 +858,7 @@ process_get_all_reply (GDBusProxy *proxy,
//g_print ("got %s -> %s\n", key, g_variant_markup_print (value, FALSE, 0, 0));
g_hash_table_insert (proxy->priv->properties,
- g_strdup (key),
+ key,
value); /* steals value */
}
out:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]