[glib] gvariant: Never break out of g_variant_iter_loop
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gvariant: Never break out of g_variant_iter_loop
- Date: Mon, 2 Jan 2012 17:34:26 +0000 (UTC)
commit 411259ddd3e6b5c5fbf900d7ab38d0d4da03f156
Author: Stef Walter <stefw collabora co uk>
Date: Mon Nov 14 18:03:47 2011 +0100
gvariant: Never break out of g_variant_iter_loop
* Document how to break out of g_variant_iter_loop style loops.
https://bugzilla.gnome.org/show_bug.cgi?id=664069
glib/gvariant.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/glib/gvariant.c b/glib/gvariant.c
index 5a4d43b..22341ff 100644
--- a/glib/gvariant.c
+++ b/glib/gvariant.c
@@ -4872,6 +4872,10 @@ g_variant_iter_next (GVariantIter *iter,
* function and g_variant_iter_next() or g_variant_iter_next_value() on
* the same iterator causes undefined behavior.
*
+ * If you break out of a such a while loop using g_variant_iter_loop() then
+ * you must free or unreference all the unpacked values as you would with
+ * g_variant_get(). Failure to do so will cause a memory leak.
+ *
* See the section on <link linkend='gvariant-format-strings'>GVariant
* Format Strings</link>.
*
@@ -4893,6 +4897,7 @@ g_variant_iter_next (GVariantIter *iter,
* g_variant_get_type_string (value));
*
* /<!-- -->* no need to free 'key' and 'value' here *<!-- -->/
+ * /<!-- -->* unless breaking out of this loop *<!-- -->/
* }
* }
* </programlisting>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]