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]

 



Hi,

On 08/19/2013 05:16 PM, Christophe Fergeau wrote:
On Mon, Aug 19, 2013 at 04:53:21PM +0200, Hans de Goede wrote:
The destroy function passed to g_slist_free_full should be passed the elements
data pointer, not the element itself.

Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
---
  gtk/glib-compat.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gtk/glib-compat.c b/gtk/glib-compat.c
index 21be1f6..c3bb8e6 100644
--- a/gtk/glib-compat.c
+++ b/gtk/glib-compat.c
@@ -88,7 +88,7 @@ g_slist_free_full(GSList         *list,

      if (free_func) {
          for (el = list; el ; el = g_slist_next(el)) {
-            free_func(el);
+            free_func(el->data);
          }

Can't we just c&p the glib function instead? This is what I do whenever
possible:

I already pushed my one liner, but you can do a follow up patch if you want.


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.

Regards,

Hans
_______________________________________________
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]