[glib] goption: document that some option args need to be freed by the callee



commit 57bd24dc4907e6959f953be0759b946c16c78386
Author: Stefan Kost <ensonic users sf net>
Date:   Tue Apr 14 11:32:59 2009 +0300

    goption: document that some option args need to be freed by the callee
    
    Option arguments where the result is stored in a string or string array need to
    be freed by the owner of the option group. Fixes #578363.
---
 glib/goption.c |    3 +++
 glib/goption.h |    5 +++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/glib/goption.c b/glib/goption.c
index 633ad2e..22d8e61 100644
--- a/glib/goption.c
+++ b/glib/goption.c
@@ -349,6 +349,9 @@ g_option_context_new (const gchar *parameter_string)
  * Frees context and all the groups which have been 
  * added to it.
  *
+ * Please note that parsed arguments need to be freed separately (see
+ * #GOptionEntry).
+ *
  * Since: 2.6
  */
 void g_option_context_free (GOptionContext *context) 
diff --git a/glib/goption.h b/glib/goption.h
index 0743e76..f096504 100644
--- a/glib/goption.h
+++ b/glib/goption.h
@@ -259,6 +259,11 @@ GQuark g_option_error_quark (void);
  *  <listitem><para>%gdouble</para></listitem>
  *  </varlistentry>
  *  </variablelist>
+ *  If @arg type is %G_OPTION_ARG_STRING or %G_OPTION_ARG_FILENAME the location
+ *  will contain a newly allocated string if the option was given. That string
+ *  needs to be freed by the callee using g_free(). Likewise if @arg type is
+ *  %G_OPTION_ARG_STRING_ARRAY or %G_OPTION_ARG_FILENAME_ARRAY, the data should
+ *  be freed using g_strfreev().
  * @description: the description for the option in <option>--help</option>
  *  output. The @description is translated using the @translate_func of the
  *  group, see g_option_group_set_translation_domain().



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]