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: pgpLN2k6zyR2Q.pgp
Description: PGP signature

_______________________________________________
Spice-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to