Re: [PATCH spice-gtk] glib-compat: g_slist_free_full: pass the right ptr to destroy (rhbz#997893)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: pgpyaRUSi14Y1.pgp
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]