On Tue, 2013-04-23 at 17:21 +0800, jiangpengfei wrote: > I have a doubt about the use of gvariant. > > In the source file: > glib-2.34.3/gio/tests/gdbus-test-codegen.c:860, > foo_igen_bar_call_test_primitive_types_sync uses a address of > ret_val_bytestring, which is a local variable which type is gchar *. > After function returns, ret_val_bytestring will be pointed to a memory > section, and I know this section is got from a inner gvariant > variable. But does someone can tell me when and how should I release > this memory?
Just call g_free() on it. As far as I can tell, this memory is allocated in g_variant_dup_string(), as called by g_variant_valist_get_nnp(), called in turn by g_variant_valist_get_leaf(). Normally the lifetime of values inside a GVariant is tied to the variant itself. But the generated functions from gdbus pull out the values with g_variant_get() - that duplicates the values for your own use. You can see those calls to g_variant_get() in gdbus-test-codegen-generated.c after you build glib. Federico _______________________________________________ desktop-devel-list mailing list desktop-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/desktop-devel-list