Plug mem leak in g_dbus_address_get_stream_sync
[platform/upstream/glib.git] / gio / gdbusaddress.c
index 6cfa5f9..5d8fc9c 100644 (file)
@@ -1,6 +1,6 @@
 /* GDBus - GLib D-Bus Library
  *
- * Copyright (C) 2008-2009 Red Hat, Inc.
+ * Copyright (C) 2008-2010 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -23,8 +23,7 @@
 #include "config.h"
 
 #include <stdlib.h>
-
-#include <glib/gi18n.h>
+#include <string.h>
 
 #include "gdbusutils.h"
 #include "gdbusaddress.h"
 #include <gio/gunixsocketaddress.h>
 #endif
 
+#include "glibintl.h"
+#include "gioalias.h"
+
 /**
  * SECTION:gdbusaddress
  * @title: D-Bus Addresses
  * @short_description: D-Bus connection endpoints
  * @include: gio/gio.h
  *
- * Routines for working with D-Bus addresses.
+ * Routines for working with D-Bus addresses. A D-Bus address is a string
+ * like "unix:tmpdir=/tmp/my-app-name". The exact format of addresses
+ * is explained in detail in the <link linkend="http://dbus.freedesktop.org/doc/dbus-specification.html&num;addresses">D-Bus specification</link>.
  */
 
 /* ---------------------------------------------------------------------------------------------------- */
@@ -58,6 +62,8 @@
  * checks.
  *
  * Returns: %TRUE if @string is a valid D-Bus address, %FALSE otherwise.
+ *
+ * Since: 2.26
  */
 gboolean
 g_dbus_is_address (const gchar *string)
@@ -335,6 +341,8 @@ is_valid_tcp (const gchar  *address_entry,
  *
  * Returns: %TRUE if @string is a valid D-Bus address that is
  * supported by this library, %FALSE if @error is set.
+ *
+ * Since: 2.26
  */
 gboolean
 g_dbus_is_supported_address (const gchar  *string,
@@ -388,10 +396,10 @@ g_dbus_is_supported_address (const gchar  *string,
 }
 
 gboolean
-_g_dbus_address_parse_entry (const gchar   *address_entry,
-                             gchar        **out_transport_name,
-                             GHashTable   **out_key_value_pairs,
-                             GError       **error)
+_g_dbus_address_parse_entry (const gchar  *address_entry,
+                             gchar       **out_transport_name,
+                             GHashTable  **out_key_value_pairs,
+                             GError      **error)
 {
   gboolean ret;
   GHashTable *key_value_pairs;
@@ -477,11 +485,11 @@ out:
  * making libgio link to libX11...
  */
 static GIOStream *
-g_dbus_address_connect (const gchar    *address_entry,
-                        const gchar    *transport_name,
-                        GHashTable     *key_value_pairs,
-                        GCancellable   *cancellable,
-                        GError        **error)
+g_dbus_address_connect (const gchar   *address_entry,
+                        const gchar   *transport_name,
+                        GHashTable    *key_value_pairs,
+                        GCancellable  *cancellable,
+                        GError       **error)
 {
   GIOStream *ret;
   GSocketConnectable *connectable;
@@ -661,10 +669,10 @@ g_dbus_address_connect (const gchar    *address_entry,
 }
 
 static GIOStream *
-g_dbus_address_try_connect_one (const gchar         *address_entry,
-                                gchar              **out_guid,
-                                GCancellable        *cancellable,
-                                GError             **error)
+g_dbus_address_try_connect_one (const gchar   *address_entry,
+                                gchar        **out_guid,
+                                GCancellable  *cancellable,
+                                GError       **error)
 {
   GIOStream *ret;
   GHashTable *key_value_pairs;
@@ -759,6 +767,8 @@ get_stream_thread_func (GSimpleAsyncResult *res,
  *
  * This is an asynchronous failable function. See
  * g_dbus_address_get_stream_sync() for the synchronous version.
+ *
+ * Since: 2.26
  */
 void
 g_dbus_address_get_stream (const gchar         *address,
@@ -796,6 +806,8 @@ g_dbus_address_get_stream (const gchar         *address,
  * Finishes an operation started with g_dbus_address_get_stream().
  *
  * Returns: A #GIOStream or %NULL if @error is set.
+ *
+ * Since: 2.26
  */
 GIOStream *
 g_dbus_address_get_stream_finish (GAsyncResult        *res,
@@ -840,12 +852,14 @@ g_dbus_address_get_stream_finish (GAsyncResult        *res,
  * g_dbus_address_get_stream() for the asynchronous version.
  *
  * Returns: A #GIOStream or %NULL if @error is set.
+ *
+ * Since: 2.26
  */
 GIOStream *
-g_dbus_address_get_stream_sync (const gchar         *address,
-                                gchar              **out_guid,
-                                GCancellable        *cancellable,
-                                GError             **error)
+g_dbus_address_get_stream_sync (const gchar   *address,
+                                gchar        **out_guid,
+                                GCancellable  *cancellable,
+                                GError       **error)
 {
   GIOStream *ret;
   gchar **addr_array;
@@ -893,6 +907,8 @@ g_dbus_address_get_stream_sync (const gchar         *address,
       g_assert (last_error != NULL);
       g_propagate_error (error, last_error);
     }
+
+  g_strfreev (addr_array);
   return ret;
 }
 
@@ -918,6 +934,8 @@ get_session_address_platform_specific (void)
  * platform specific mechanisms.
  *
  * Returns: A valid D-Bus address string for @bus_type or %NULL if @error is set.
+ *
+ * Since: 2.26
  */
 gchar *
 g_dbus_address_get_for_bus_sync (GBusType       bus_type,
@@ -1002,3 +1020,6 @@ g_dbus_address_get_for_bus_sync (GBusType       bus_type,
  out:
   return ret;
 }
+
+#define __G_DBUS_ADDRESS_C__
+#include "gioaliasdef.c"