GVariant: add new g_variant_new_take_string() API
authorRyan Lortie <desrt@desrt.ca>
Sat, 20 Apr 2013 15:44:53 +0000 (11:44 -0400)
committerRyan Lortie <desrt@desrt.ca>
Sat, 20 Apr 2013 22:58:24 +0000 (18:58 -0400)
commitdbb65b54651a88b9691b156bf19b53fbe4a4bd5a
tree48da41f1d4684b18f7355d49b281694ccbad9aae
parenta2a44a9617098ef061b1fd026ea44d381aa5ccec
GVariant: add new g_variant_new_take_string() API

Lots of people have variously asked for APIs like
g_variant_new_string_printf() in order to avoid having to use
g_strdup_printf(), create a GVariant using g_variant_new_string(), then
free the temporary string.

Instead of supporting that, plus a million other potential cases,
introduce g_variant_new_take_string() as a compromise.

It's not possible to write:

 v = g_variant_new_take_string (g_strdup_printf (....));

to get the desired result and avoid the extra copies.  In addition, it
works with many other functions.

https://bugzilla.gnome.org/show_bug.cgi?id=698455
docs/reference/glib/glib-sections.txt
glib/gvariant.c
glib/gvariant.h