diff --git a/ChangeLog b/ChangeLog index 862d2e3495..5c1bc054dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2007-05-22 Michael Natterer <mitch@gimp.org> + + * app/actions/data-commands.c + * app/base/boundary.c + * app/base/gimphistogram.c + * app/base/gimplut.c + * app/base/temp-buf.c + * app/core/gimpcontainer.c + * app/core/gimpgradient.c + * app/core/gimpparamspecs.c + * app/core/gimpundo.c + * app/plug-in/gimpplugin-cleanup.c + * app/plug-in/gimppluginmanager-data.c + * app/plug-in/gimppluginmanager-help-domain.c + * app/plug-in/gimppluginmanager-locale-domain.c + * app/plug-in/gimppluginmanager-menu-branch.c + * app/plug-in/gimppluginprocframe.c + * app/vectors/gimpanchor.c + * app/widgets/gimpsessioninfo.c: use GSlice instead of g_new/g_free + for structs of fixed size. + 2007-05-22 Sven Neumann <sven@gimp.org> * app/widgets/gimpprogressbox.c (gimp_progress_box_progress_start) diff --git a/app/actions/data-commands.c b/app/actions/data-commands.c index 430fcdc483..ab999c9656 100644 --- a/app/actions/data-commands.c +++ b/app/actions/data-commands.c @@ -220,7 +220,7 @@ data_delete_cmd_callback (GtkAction *action, GimpDataDeleteData *delete_data; GtkWidget *dialog; - delete_data = g_new0 (GimpDataDeleteData, 1); + delete_data = g_slice_new0 (GimpDataDeleteData); delete_data->view = view; delete_data->data = data; @@ -326,5 +326,5 @@ data_delete_confirm_response (GtkWidget *dialog, } } - g_free (delete_data); + g_slice_free (GimpDataDeleteData, delete_data); } diff --git a/app/base/boundary.c b/app/base/boundary.c index 58bd3dfb42..ff490bc90b 100644 --- a/app/base/boundary.c +++ b/app/base/boundary.c @@ -346,7 +346,7 @@ boundary_simplify (BoundSeg *sorted_segs, static Boundary * boundary_new (PixelRegion *PR) { - Boundary *boundary = g_new0 (Boundary, 1); + Boundary *boundary = g_slice_new0 (Boundary); if (PR) { @@ -389,7 +389,7 @@ boundary_free (Boundary *boundary, g_free (boundary->empty_segs_c); g_free (boundary->empty_segs_l); - g_free (boundary); + g_slice_free (Boundary, boundary); return segs; } diff --git a/app/base/gimphistogram.c b/app/base/gimphistogram.c index 6e265927d5..f24f64570f 100644 --- a/app/base/gimphistogram.c +++ b/app/base/gimphistogram.c @@ -66,7 +66,7 @@ static void gimp_histogram_calculate_sub_region (GimpHistogram *histogram, GimpHistogram * gimp_histogram_new (void) { - GimpHistogram *histogram = g_new0 (GimpHistogram, 1); + GimpHistogram *histogram = g_slice_new0 (GimpHistogram); #ifdef ENABLE_MP g_static_mutex_init (&histogram->mutex); @@ -81,7 +81,7 @@ gimp_histogram_free (GimpHistogram *histogram) g_return_if_fail (histogram != NULL); gimp_histogram_free_values (histogram); - g_free (histogram); + g_slice_free (GimpHistogram, histogram); } void diff --git a/app/base/gimplut.c b/app/base/gimplut.c index f7e1430211..16bbf0a0ba 100644 --- a/app/base/gimplut.c +++ b/app/base/gimplut.c @@ -33,7 +33,7 @@ gimp_lut_new (void) { GimpLut *lut; - lut = g_new (GimpLut, 1); + lut = g_slice_new (GimpLut); lut->luts = NULL; lut->nchannels = 0; @@ -50,7 +50,7 @@ gimp_lut_free (GimpLut *lut) g_free (lut->luts[i]); g_free (lut->luts); - g_free (lut); + g_slice_free (GimpLut, lut); } void diff --git a/app/base/temp-buf.c b/app/base/temp-buf.c index 06f90bb2bb..174552a899 100644 --- a/app/base/temp-buf.c +++ b/app/base/temp-buf.c @@ -52,7 +52,7 @@ temp_buf_new (gint width, g_return_val_if_fail (width > 0 && height > 0, NULL); g_return_val_if_fail (bytes > 0, NULL); - temp = g_new (TempBuf, 1); + temp = g_slice_new (TempBuf); temp->width = width; temp->height = height; @@ -352,7 +352,7 @@ temp_buf_free (TempBuf *temp_buf) if (temp_buf->data) g_free (temp_buf->data); - g_free (temp_buf); + g_slice_free (TempBuf, temp_buf); } guchar * diff --git a/app/core/gimpcontainer.c b/app/core/gimpcontainer.c index d5d4df6dc6..f72e230c09 100644 --- a/app/core/gimpcontainer.c +++ b/app/core/gimpcontainer.c @@ -865,7 +865,7 @@ gimp_container_add_handler (GimpContainer *container, g_return_val_if_fail (g_signal_lookup (signame, container->children_type), 0); - handler = g_new0 (GimpContainerHandler, 1); + handler = g_slice_new0 (GimpContainerHandler); /* create a unique key for this handler */ key = g_strdup_printf ("%s-%d", signame, handler_id++); @@ -939,5 +939,5 @@ gimp_container_remove_handler (GimpContainer *container, container->handlers = g_list_remove (container->handlers, handler); g_free (handler->signame); - g_free (handler); + g_slice_free (GimpContainerHandler, handler); } diff --git a/app/core/gimpgradient.c b/app/core/gimpgradient.c index 8bdd11d986..60797216f1 100644 --- a/app/core/gimpgradient.c +++ b/app/core/gimpgradient.c @@ -592,7 +592,7 @@ gimp_gradient_segment_new (void) { GimpGradientSegment *seg; - seg = g_new (GimpGradientSegment, 1); + seg = g_slice_new (GimpGradientSegment); seg->left = 0.0; seg->middle = 0.5; @@ -618,22 +618,15 @@ gimp_gradient_segment_free (GimpGradientSegment *seg) { g_return_if_fail (seg != NULL); - g_free (seg); + g_slice_free (GimpGradientSegment, seg); } void gimp_gradient_segments_free (GimpGradientSegment *seg) { - GimpGradientSegment *tmp; - g_return_if_fail (seg != NULL); - while (seg) - { - tmp = seg->next; - gimp_gradient_segment_free (seg); - seg = tmp; - } + g_slice_free_chain (GimpGradientSegment, seg, next); } GimpGradientSegment * diff --git a/app/core/gimpparamspecs.c b/app/core/gimpparamspecs.c index 9df585a7a9..c03d0bc1a6 100644 --- a/app/core/gimpparamspecs.c +++ b/app/core/gimpparamspecs.c @@ -1829,7 +1829,7 @@ gimp_array_new (const guint8 *data, g_return_val_if_fail ((data == NULL && length == 0) || (data != NULL && length > 0), NULL); - array = g_new0 (GimpArray, 1); + array = g_slice_new0 (GimpArray); array->data = static_data ? (guint8 *) data : g_memdup (data, length); array->length = length; @@ -1855,7 +1855,7 @@ gimp_array_free (GimpArray *array) if (! array->static_data) g_free (array->data); - g_free (array); + g_slice_free (GimpArray, array); } } @@ -2544,7 +2544,7 @@ gimp_string_array_new (const gchar **data, g_return_val_if_fail ((data == NULL && length == 0) || (data != NULL && length > 0), NULL); - array = g_new0 (GimpArray, 1); + array = g_slice_new0 (GimpArray); if (! static_data) { @@ -2593,7 +2593,7 @@ gimp_string_array_free (GimpArray *array) g_free (array->data); } - g_free (array); + g_slice_free (GimpArray, array); } } diff --git a/app/core/gimpundo.c b/app/core/gimpundo.c index f13f5911d0..cb29cf4d28 100644 --- a/app/core/gimpundo.c +++ b/app/core/gimpundo.c @@ -404,7 +404,7 @@ gimp_undo_idle_free (GimpUndoIdle *idle) if (idle->context) g_object_unref (idle->context); - g_free (idle); + g_slice_free (GimpUndoIdle, idle); } void @@ -424,7 +424,7 @@ gimp_undo_create_preview (GimpUndo *undo, } else { - GimpUndoIdle *idle = g_new0 (GimpUndoIdle, 1); + GimpUndoIdle *idle = g_slice_new0 (GimpUndoIdle); idle->undo = undo; diff --git a/app/plug-in/gimpplugin-cleanup.c b/app/plug-in/gimpplugin-cleanup.c index bf9b497c16..0611a52eed 100644 --- a/app/plug-in/gimpplugin-cleanup.c +++ b/app/plug-in/gimpplugin-cleanup.c @@ -70,7 +70,7 @@ gimp_plug_in_cleanup_undo_group_start (GimpPlugIn *plug_in, if (! cleanup) { - cleanup = g_new0 (GimpPlugInCleanupImage, 1); + cleanup = g_slice_new0 (GimpPlugInCleanupImage); cleanup->image = image; cleanup->undo_group_count = image->group_count; @@ -100,7 +100,7 @@ gimp_plug_in_cleanup_undo_group_end (GimpPlugIn *plug_in, if (cleanup->undo_group_count == image->group_count - 1) { proc_frame->cleanups = g_list_remove (proc_frame->cleanups, cleanup); - g_free (cleanup); + g_slice_free (GimpPlugInCleanupImage, cleanup); } return TRUE; @@ -143,7 +143,7 @@ gimp_plug_in_cleanup (GimpPlugIn *plug_in, } } - g_free (cleanup); + g_slice_free (GimpPlugInCleanupImage, cleanup); } g_list_free (proc_frame->cleanups); diff --git a/app/plug-in/gimppluginmanager-data.c b/app/plug-in/gimppluginmanager-data.c index 760dcf799a..eb4eeb9415 100644 --- a/app/plug-in/gimppluginmanager-data.c +++ b/app/plug-in/gimppluginmanager-data.c @@ -59,7 +59,7 @@ gimp_plug_in_manager_data_free (GimpPlugInManager *manager) g_free (data->identifier); g_free (data->data); - g_free (data); + g_slice_free (GimpPlugInData, data); } g_list_free (manager->data_list); @@ -69,9 +69,9 @@ gimp_plug_in_manager_data_free (GimpPlugInManager *manager) void gimp_plug_in_manager_set_data (GimpPlugInManager *manager, - const gchar *identifier, - gint32 bytes, - const guint8 *data) + const gchar *identifier, + gint32 bytes, + const guint8 *data) { GimpPlugInData *plug_in_data; GList *list; @@ -92,7 +92,7 @@ gimp_plug_in_manager_set_data (GimpPlugInManager *manager, /* If there isn't already data with the specified identifier, create one */ if (list == NULL) { - plug_in_data = g_new0 (GimpPlugInData, 1); + plug_in_data = g_slice_new0 (GimpPlugInData); plug_in_data->identifier = g_strdup (identifier); manager->data_list = g_list_prepend (manager->data_list, plug_in_data); diff --git a/app/plug-in/gimppluginmanager-help-domain.c b/app/plug-in/gimppluginmanager-help-domain.c index ef3a22c3c7..a670681684 100644 --- a/app/plug-in/gimppluginmanager-help-domain.c +++ b/app/plug-in/gimppluginmanager-help-domain.c @@ -54,7 +54,7 @@ gimp_plug_in_manager_help_domain_exit (GimpPlugInManager *manager) g_free (domain->prog_name); g_free (domain->domain_name); g_free (domain->domain_uri); - g_free (domain); + g_slice_free (GimpPlugInHelpDomain, domain); } g_slist_free (manager->help_domains); @@ -73,7 +73,7 @@ gimp_plug_in_manager_add_help_domain (GimpPlugInManager *manager, g_return_if_fail (prog_name != NULL); g_return_if_fail (domain_name != NULL); - domain = g_new (GimpPlugInHelpDomain, 1); + domain = g_slice_new (GimpPlugInHelpDomain); domain->prog_name = g_strdup (prog_name); domain->domain_name = g_strdup (domain_name); diff --git a/app/plug-in/gimppluginmanager-locale-domain.c b/app/plug-in/gimppluginmanager-locale-domain.c index 660214a4e2..10a281ef5a 100644 --- a/app/plug-in/gimppluginmanager-locale-domain.c +++ b/app/plug-in/gimppluginmanager-locale-domain.c @@ -59,7 +59,7 @@ gimp_plug_in_manager_locale_domain_exit (GimpPlugInManager *manager) g_free (domain->prog_name); g_free (domain->domain_name); g_free (domain->domain_path); - g_free (domain); + g_slice_free (GimpPlugInLocaleDomain, domain); } g_slist_free (manager->locale_domains); @@ -78,7 +78,7 @@ gimp_plug_in_manager_add_locale_domain (GimpPlugInManager *manager, g_return_if_fail (prog_name != NULL); g_return_if_fail (domain_name != NULL); - domain = g_new (GimpPlugInLocaleDomain, 1); + domain = g_slice_new (GimpPlugInLocaleDomain); domain->prog_name = g_strdup (prog_name); domain->domain_name = g_strdup (domain_name); diff --git a/app/plug-in/gimppluginmanager-menu-branch.c b/app/plug-in/gimppluginmanager-menu-branch.c index 22a3e6176e..d62cc54ed1 100644 --- a/app/plug-in/gimppluginmanager-menu-branch.c +++ b/app/plug-in/gimppluginmanager-menu-branch.c @@ -44,7 +44,7 @@ gimp_plug_in_manager_menu_branch_exit (GimpPlugInManager *manager) g_free (branch->prog_name); g_free (branch->menu_path); g_free (branch->menu_label); - g_free (branch); + g_slice_free (GimpPlugInMenuBranch, branch); } g_slist_free (manager->menu_branches); @@ -64,7 +64,7 @@ gimp_plug_in_manager_add_menu_branch (GimpPlugInManager *manager, g_return_if_fail (menu_path != NULL); g_return_if_fail (menu_label != NULL); - branch = g_new (GimpPlugInMenuBranch, 1); + branch = g_slice_new (GimpPlugInMenuBranch); branch->prog_name = g_strdup (prog_name); branch->menu_path = g_strdup (menu_path); diff --git a/app/plug-in/gimppluginprocframe.c b/app/plug-in/gimppluginprocframe.c index b4ae138344..7639485668 100644 --- a/app/plug-in/gimppluginprocframe.c +++ b/app/plug-in/gimppluginprocframe.c @@ -48,7 +48,7 @@ gimp_plug_in_proc_frame_new (GimpContext *context, g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL); g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (procedure), NULL); - proc_frame = g_new0 (GimpPlugInProcFrame, 1); + proc_frame = g_slice_new0 (GimpPlugInProcFrame); proc_frame->ref_count = 1; @@ -151,7 +151,7 @@ gimp_plug_in_proc_frame_unref (GimpPlugInProcFrame *proc_frame, if (proc_frame->ref_count < 1) { gimp_plug_in_proc_frame_dispose (proc_frame, plug_in); - g_free (proc_frame); + g_slice_free (GimpPlugInProcFrame, proc_frame); } } diff --git a/app/vectors/gimpanchor.c b/app/vectors/gimpanchor.c index f792ed31cc..6bc2dbe3c2 100644 --- a/app/vectors/gimpanchor.c +++ b/app/vectors/gimpanchor.c @@ -35,8 +35,8 @@ gimp_anchor_get_type (void) if (!anchor_type) anchor_type = g_boxed_type_register_static ("GimpAnchor", - (GBoxedCopyFunc) gimp_anchor_copy, - (GBoxedFreeFunc) gimp_anchor_free); + (GBoxedCopyFunc) gimp_anchor_copy, + (GBoxedFreeFunc) gimp_anchor_free); return anchor_type; } @@ -45,7 +45,7 @@ GimpAnchor * gimp_anchor_new (GimpAnchorType type, const GimpCoords *position) { - GimpAnchor *anchor = g_new0 (GimpAnchor, 1); + GimpAnchor *anchor = g_slice_new0 (GimpAnchor); anchor->type = type; @@ -58,11 +58,21 @@ gimp_anchor_new (GimpAnchorType type, GimpAnchor * gimp_anchor_copy (const GimpAnchor *anchor) { - return g_memdup (anchor, sizeof (GimpAnchor)); + GimpAnchor *new; + + g_return_val_if_fail (anchor != NULL, NULL); + + new = g_slice_new (GimpAnchor); + + *new = *anchor; + + return new; } void gimp_anchor_free (GimpAnchor *anchor) { - g_free (anchor); + g_return_if_fail (anchor != NULL); + + g_slice_free (GimpAnchor, anchor); } diff --git a/app/widgets/gimpsessioninfo.c b/app/widgets/gimpsessioninfo.c index 51dfddb810..822409cc0a 100644 --- a/app/widgets/gimpsessioninfo.c +++ b/app/widgets/gimpsessioninfo.c @@ -142,7 +142,7 @@ gimp_session_info_aux_new (const gchar *name, g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (value != NULL, NULL); - aux = g_new0 (GimpSessionInfoAux, 1); + aux = g_slice_new0 (GimpSessionInfoAux); aux->name = g_strdup (name); aux->value = g_strdup (value); @@ -157,7 +157,7 @@ gimp_session_info_aux_free (GimpSessionInfoAux *aux) g_free (aux->name); g_free (aux->value); - g_free (aux); + g_slice_free (GimpSessionInfoAux, aux); } GList * @@ -1217,7 +1217,7 @@ session_info_aux_deserialize (GScanner *scanner, case G_TOKEN_IDENTIFIER: { - aux_info = g_new0 (GimpSessionInfoAux, 1); + aux_info = g_slice_new0 (GimpSessionInfoAux); aux_info->name = g_strdup (scanner->value.v_identifier);