diff --git a/ChangeLog b/ChangeLog index 7142d4ef0a..64ab725e34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-05-22 Sven Neumann + + * app/core/gimparea.[ch] + * app/core/gimpprojection.c + * app/display/gimpdisplay.c: use GSlice to allocate GimpArea and + sanitize the API. + 2007-05-22 Sven Neumann * app/base/tile-manager.[ch] diff --git a/app/core/gimparea.c b/app/core/gimparea.c index 1f3bf7880b..f84f38efa3 100644 --- a/app/core/gimparea.c +++ b/app/core/gimparea.c @@ -34,9 +34,7 @@ gimp_area_new (gint x1, gint x2, gint y2) { - GimpArea *area; - - area = g_new (GimpArea, 1); + GimpArea *area = g_slice_new (GimpArea); area->x1 = x1; area->y1 = y1; @@ -46,6 +44,13 @@ gimp_area_new (gint x1, return area; } +void +gimp_area_free (GimpArea *area) +{ + g_slice_free (GimpArea, area); +} + + /* * As far as I can tell, this function takes a GimpArea and unifies it with * an existing list of GimpAreas, trying to avoid overdraw. [adam] @@ -81,7 +86,7 @@ gimp_area_list_process (GSList *list, area->x2 = MAX (area->x2, ga2->x2); area->y2 = MAX (area->y2, ga2->y2); - g_free (ga2); + g_slice_free (GimpArea, ga2); } } @@ -91,14 +96,13 @@ gimp_area_list_process (GSList *list, return new_list; } -GSList * -gimp_area_list_free (GSList *list) +void +gimp_area_list_free (GSList *areas) { - if (list) - { - g_slist_foreach (list, (GFunc) g_free, NULL); - g_slist_free (list); - } + GSList *list; - return NULL; + for (list = areas; list; list = list->next) + gimp_area_free (list->data); + + g_slist_free (list); } diff --git a/app/core/gimparea.h b/app/core/gimparea.h index 9496e8b5f4..16009da579 100644 --- a/app/core/gimparea.h +++ b/app/core/gimparea.h @@ -30,10 +30,11 @@ GimpArea * gimp_area_new (gint x1, gint y1, gint x2, gint y2); +void gimp_area_free (GimpArea *area); GSList * gimp_area_list_process (GSList *list, GimpArea *area); -GSList * gimp_area_list_free (GSList *list); +void gimp_area_list_free (GSList *list); #endif /* __GIMP_AREA_H__ */ diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c index 63088a325a..3932f319e3 100644 --- a/app/core/gimpprojection.c +++ b/app/core/gimpprojection.c @@ -455,26 +455,28 @@ gimp_projection_flush_whenever (GimpProjection *proj, } /* Free the update lists */ - proj->update_areas = gimp_area_list_free (proj->update_areas); + gimp_area_list_free (proj->update_areas); + proj->update_areas = NULL; } } static void gimp_projection_idle_render_init (GimpProjection *proj) { - GSList *list; - GimpArea *area; + GSList *list; - /* We need to merge the IdleRender's and the GimpProjection's update_areas list - * to keep track of which of the updates have been flushed and hence need - * to be drawn. + /* We need to merge the IdleRender's and the GimpProjection's update_areas + * list to keep track of which of the updates have been flushed and hence + * need to be drawn. */ for (list = proj->update_areas; list; list = g_slist_next (list)) { - area = g_memdup (list->data, sizeof (GimpArea)); + GimpArea *area = list->data; proj->idle_render.update_areas = - gimp_area_list_process (proj->idle_render.update_areas, area); + gimp_area_list_process (proj->idle_render.update_areas, + gimp_area_new (area->x1, area->y1, + area->x2, area->y2)); } /* If an idlerender was already running, merge the remainder of its @@ -483,7 +485,7 @@ gimp_projection_idle_render_init (GimpProjection *proj) */ if (proj->idle_render.idle_id) { - area = + GimpArea *area = gimp_area_new (proj->idle_render.base_x, proj->idle_render.y, proj->idle_render.base_x + proj->idle_render.width, @@ -581,7 +583,7 @@ gimp_projection_idle_render_next_area (GimpProjection *proj) if (! proj->idle_render.update_areas) return FALSE; - area = (GimpArea *) proj->idle_render.update_areas->data; + area = proj->idle_render.update_areas->data; proj->idle_render.update_areas = g_slist_remove (proj->idle_render.update_areas, area); @@ -591,7 +593,7 @@ gimp_projection_idle_render_next_area (GimpProjection *proj) proj->idle_render.width = area->x2 - area->x1; proj->idle_render.height = area->y2 - area->y1; - g_free (area); + gimp_area_free (area); return TRUE; } diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c index 93543ceda4..060c95a00b 100644 --- a/app/display/gimpdisplay.c +++ b/app/display/gimpdisplay.c @@ -384,7 +384,8 @@ gimp_display_delete (GimpDisplay *display) tool_manager_focus_display_active (display->image->gimp, NULL); /* free the update area lists */ - display->update_areas = gimp_area_list_free (display->update_areas); + gimp_area_list_free (display->update_areas); + display->update_areas = NULL; if (display->shell) { @@ -524,8 +525,8 @@ gimp_display_flush_whenever (GimpDisplay *display, (area->y2 - area->y1)); } } - - display->update_areas = gimp_area_list_free (display->update_areas); + gimp_area_list_free (display->update_areas); + display->update_areas = NULL; } gimp_display_shell_flush (GIMP_DISPLAY_SHELL (display->shell), now);