From 22616e80f4d5141d632e01e0db17d413b99e55b9 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Wed, 18 Oct 2000 17:51:25 +0000 Subject: [PATCH] as Mitch pointed out we used to leak GList memory here. The new 2000-10-18 Sven Neumann * app/cursorutil.c (gtkutil_compress_motion): as Mitch pointed out we used to leak GList memory here. The new implementation should be faster too, since it prepends to the list instead of appending. --- ChangeLog | 6 ++++++ app/cursorutil.c | 21 ++++++++++++--------- app/widgets/gimpcursor.c | 21 ++++++++++++--------- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3fb47c49f..4d81a231d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2000-10-18 Sven Neumann + + * app/cursorutil.c (gtkutil_compress_motion): as Mitch pointed out we + used to leak GList memory here. The new implementation should be + faster too, since it prepends to the list instead of appending. + 2000-10-18 Michael Natterer * plug-ins/helpbrowser/Makefile.am: added $GTK_CFLAGS and $GTK_LIBS. diff --git a/app/cursorutil.c b/app/cursorutil.c index 57ec03097d..c3a1e4da6d 100644 --- a/app/cursorutil.c +++ b/app/cursorutil.c @@ -511,8 +511,9 @@ gtkutil_compress_motion (GtkWidget *widget, gdouble *lastmotion_y) { GdkEvent *event; - GList *requeued_events = NULL; - gboolean success = FALSE; + GList *requeued_events = NULL; + GList *list; + gboolean success = FALSE; /* Move the entire GDK event queue to a private list, filtering out any motion events for the desired widget. */ @@ -535,20 +536,22 @@ gtkutil_compress_motion (GtkWidget *widget, } else { - requeued_events = g_list_append (requeued_events, event); + requeued_events = g_list_prepend (requeued_events, event); } } /* Replay the remains of our private event list back into the event queue in order. */ - while (requeued_events) - { - gdk_event_put ((GdkEvent*) requeued_events->data); - gdk_event_free ((GdkEvent*) requeued_events->data); - requeued_events = - g_list_remove_link (requeued_events, requeued_events); + requeued_events = g_list_reverse (requeued_events); + + for (list = requeued_events; list; list = g_list_next (list)) + { + gdk_event_put ((GdkEvent*) list->data); + gdk_event_free ((GdkEvent*) list->data); } + g_list_free (requeued_events); + return success; } diff --git a/app/widgets/gimpcursor.c b/app/widgets/gimpcursor.c index 57ec03097d..c3a1e4da6d 100644 --- a/app/widgets/gimpcursor.c +++ b/app/widgets/gimpcursor.c @@ -511,8 +511,9 @@ gtkutil_compress_motion (GtkWidget *widget, gdouble *lastmotion_y) { GdkEvent *event; - GList *requeued_events = NULL; - gboolean success = FALSE; + GList *requeued_events = NULL; + GList *list; + gboolean success = FALSE; /* Move the entire GDK event queue to a private list, filtering out any motion events for the desired widget. */ @@ -535,20 +536,22 @@ gtkutil_compress_motion (GtkWidget *widget, } else { - requeued_events = g_list_append (requeued_events, event); + requeued_events = g_list_prepend (requeued_events, event); } } /* Replay the remains of our private event list back into the event queue in order. */ - while (requeued_events) - { - gdk_event_put ((GdkEvent*) requeued_events->data); - gdk_event_free ((GdkEvent*) requeued_events->data); - requeued_events = - g_list_remove_link (requeued_events, requeued_events); + requeued_events = g_list_reverse (requeued_events); + + for (list = requeued_events; list; list = g_list_next (list)) + { + gdk_event_put ((GdkEvent*) list->data); + gdk_event_free ((GdkEvent*) list->data); } + g_list_free (requeued_events); + return success; }