[Spice-devel] [PATCH spice-gtk] glib-compat: g_slist_free_full: pass the right ptr to destroy (rhbz#997893)
Christophe Fergeau
cfergeau at redhat.com
Mon Aug 19 08:30:51 PDT 2013
On Mon, Aug 19, 2013 at 05:20:54PM +0200, Hans de Goede wrote:
> >
> >void
> >g_slist_free_full (GSList *list, GDestroyNotify free_func)
> >{
> > g_slist_foreach (list, (GFunc) free_func, NULL);
> > g_slist_free (list);
> >}
>
> Is this really in glib upstream? It is quite ugly with the function
> cast, GDestroyNotify and GFunc have significantly different prototypes,
> I consider this a rather hacky implementation.
>
Yes it is from glib upstream, we want g_slist_free_full callback to be a
function with just one argument, the list element to destroy.
GDestroyNotify matches that.
g_slist_foreach predates g_slist_free_full by a few years at least, and its
callback expects 2 arguments, the list element being iterated over, plus
some user-specified data, which is what GFunc is.
So using the 2 different types here makes sense, and the cast is not unseen
in glib using code.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20130819/89bd9fc8/attachment.pgp>
More information about the Spice-devel
mailing list