*_get_name inconstancy
Eric Trousset
etrousset at awox.com
Thu Apr 17 00:48:40 PDT 2014
fair enough :)
> -----Original Message-----
> From: gstreamer-devel [mailto:gstreamer-devel-
> bounces at lists.freedesktop.org] On Behalf Of Tim Müller
> Sent: mercredi 16 avril 2014 12:33
> To: gstreamer-devel at lists.freedesktop.org
> Subject: Re: *_get_name inconstancy
>
> On Wed, 2014-04-16 at 12:13 +0200, Eric Trousset wrote:
>
> Hi,
>
> > In gstreamer some _get_name function return const ghar* and don’t
> > need to be freed whereas some others (the one ending up calling
> > gst_object_get_name thru a #define) returns a gchar* and do need to be
> > freed.
> >
> >
> > Wouldn’t it be better if all the _get_name function had the same
> > behavior?
>
> Well, yes, but at the same time it also doesn't seem like a good idea to cause
> inconvenience (return value assignment + g_free) and inefficiencies
> (g_strdup) for no good reason other than consistency :)
>
> When we return a copy that's usually for thread-safety reasons, because the
> value may change. This happens usually with refcounted GObjects (pads,
> elements).
>
> For others the return value is a const gchar * because it maps to a constant
> string, like nick names for enum values.
>
> For things like gst_structure_get_name() it's also convenience, since we
> know the value can't be changed in another thread while we're looking at the
> structure (bugs aside).
>
> Cheers
> -Tim
>
> --
> Tim Müller, Centricular Ltd - http://www.centricular.com
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list