mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 22:16:16 +01:00
GVariantBuilder: small documentation fixes
The examples for g_variant_builder_add and g_variant_builder_add_parsed were leaking a heap-allocated builder. Fix that by converting the examples to stack allocation. https://bugzilla.gnome.org/show_bug.cgi?id=697585 https://bugzilla.gnome.org/show_bug.cgi?id=703522
This commit is contained in:
parent
4382e8b876
commit
3309055878
@ -2521,23 +2521,23 @@ g_variant_new_parsed (const gchar *format,
|
||||
*
|
||||
* This function might be used as follows:
|
||||
*
|
||||
* <programlisting>
|
||||
* |[
|
||||
* GVariant *
|
||||
* make_pointless_dictionary (void)
|
||||
* {
|
||||
* GVariantBuilder *builder;
|
||||
* GVariantBuilder builder;
|
||||
* int i;
|
||||
*
|
||||
* builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
|
||||
* g_variant_builder_add_parsed (builder, "{'width', <%i>}", 600);
|
||||
* g_variant_builder_add_parsed (builder, "{'title', <%s>}", "foo");
|
||||
* g_variant_builder_add_parsed (builder, "{'transparency', <0.5>}");
|
||||
* return g_variant_builder_end (builder);
|
||||
* g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
|
||||
* g_variant_builder_add_parsed (&builder, "{'width', <%i>}", 600);
|
||||
* g_variant_builder_add_parsed (&builder, "{'title', <%s>}", "foo");
|
||||
* g_variant_builder_add_parsed (&builder, "{'transparency', <0.5>}");
|
||||
* return g_variant_builder_end (&builder);
|
||||
* }
|
||||
* </programlisting>
|
||||
* ]|
|
||||
*
|
||||
* Since: 2.26
|
||||
**/
|
||||
*/
|
||||
void
|
||||
g_variant_builder_add_parsed (GVariantBuilder *builder,
|
||||
const gchar *format,
|
||||
|
@ -4884,7 +4884,7 @@ g_variant_get_va (GVariant *value,
|
||||
/* Varargs-enabled Utility Functions {{{1 */
|
||||
|
||||
/**
|
||||
* g_variant_builder_add: (skp)
|
||||
* g_variant_builder_add: (skip)
|
||||
* @builder: a #GVariantBuilder
|
||||
* @format_string: a #GVariant varargs format string
|
||||
* @...: arguments, as per @format_string
|
||||
@ -4896,28 +4896,28 @@ g_variant_get_va (GVariant *value,
|
||||
*
|
||||
* This function might be used as follows:
|
||||
*
|
||||
* <programlisting>
|
||||
* |[
|
||||
* GVariant *
|
||||
* make_pointless_dictionary (void)
|
||||
* {
|
||||
* GVariantBuilder *builder;
|
||||
* GVariantBuilder builder;
|
||||
* int i;
|
||||
*
|
||||
* builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
|
||||
* g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
|
||||
* for (i = 0; i < 16; i++)
|
||||
* {
|
||||
* gchar buf[3];
|
||||
*
|
||||
* sprintf (buf, "%d", i);
|
||||
* g_variant_builder_add (builder, "{is}", i, buf);
|
||||
* g_variant_builder_add (&builder, "{is}", i, buf);
|
||||
* }
|
||||
*
|
||||
* return g_variant_builder_end (builder);
|
||||
* return g_variant_builder_end (&builder);
|
||||
* }
|
||||
* </programlisting>
|
||||
* ]|
|
||||
*
|
||||
* Since: 2.24
|
||||
**/
|
||||
*/
|
||||
void
|
||||
g_variant_builder_add (GVariantBuilder *builder,
|
||||
const gchar *format_string,
|
||||
|
Loading…
Reference in New Issue
Block a user