Hi again,

Yes, g_value_set_string() does call g_strdup().

bests,
Joël

On Thu, Feb 7, 2019 at 5:20 AM Joël Krähemann <jkraehem...@gmail.com> wrote:
>
> Hi all,
>
> Currently, I do my properties like following:
>
> http://git.savannah.nongnu.org/cgit/gsequencer.git/tree/ags/lib/ags_turtle.c?h=2.1.x#n175
> http://git.savannah.nongnu.org/cgit/gsequencer.git/tree/ags/lib/ags_turtle.c?h=2.1.x#n218
>
> Is it ok to do g_strdup() and pass it to g_value_set_string()?
> Or does g_value_set_string() duplicate the string for me?
>
> Does the following make any sense?
>
> g_value_set_string(value, g_strdup(turtle->filename));
>
> This sample code is from GLib-2.0 API Reference Manual:
>
> ================================
>
> gint intval;
> gchar *strval;
> GObject *objval;
>
> g_object_get (my_object,
>               "int-property", &intval,
>               "str-property", &strval,
>               "obj-property", &objval,
>               NULL);
>
> // Do something with intval, strval, objval
>
> g_free (strval);
> g_object_unref (objval);
>
> ================================
>
> Since I have to free the string, I just wonder if I need to g_strdup() it.
>
> bests,
> Joël
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to