diff --git a/ChangeLog b/ChangeLog index 2e1593643e..e0d039d910 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-05-22 Sven Neumann + + * libgimpwidgets/gimpsizeentry.c + * libgimpwidgets/gimpquerybox.c: allocate structs using GSlice. + 2007-05-22 Sven Neumann * libgimpconfig/gimpconfigwriter.c: use GSlice for the diff --git a/libgimpwidgets/gimpquerybox.c b/libgimpwidgets/gimpquerybox.c index aa3710ca61..c4fdd01ad2 100644 --- a/libgimpwidgets/gimpquerybox.c +++ b/libgimpwidgets/gimpquerybox.c @@ -70,6 +70,7 @@ static QueryBox * create_query_box (const gchar *title, gpointer callback_data); static void query_box_disconnect (QueryBox *query_box); +static void query_box_destroy (QueryBox *query_box); static void string_query_box_response (GtkWidget *widget, gint response_id, @@ -118,7 +119,7 @@ create_query_box (const gchar *title, g_return_val_if_fail (object == NULL || G_IS_OBJECT (object), NULL); g_return_val_if_fail (object == NULL || signal != NULL, NULL); - query_box = g_new0 (QueryBox, 1); + query_box = g_slice_new0 (QueryBox); query_box->qbox = gimp_dialog_new (title, "gimp-query-box", parent, 0, @@ -547,6 +548,16 @@ query_box_disconnect (QueryBox *query_box) query_box); } +static void +query_box_destroy (QueryBox *query_box) +{ + /* Destroy the box */ + if (query_box->qbox) + gtk_widget_destroy (query_box->qbox); + + g_slice_free (QueryBox, query_box); +} + static void string_query_box_response (GtkWidget *widget, gint response_id, @@ -565,11 +576,7 @@ string_query_box_response (GtkWidget *widget, string, query_box->callback_data); - /* Destroy the box */ - if (query_box->qbox) - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); + query_box_destroy (query_box); } static void @@ -590,11 +597,7 @@ int_query_box_response (GtkWidget *widget, value, query_box->callback_data); - /* Destroy the box */ - if (query_box->qbox) - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); + query_box_destroy (query_box); } static void @@ -615,11 +618,7 @@ double_query_box_response (GtkWidget *widget, value, query_box->callback_data); - /* Destroy the box */ - if (query_box->qbox) - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); + query_box_destroy (query_box); } static void @@ -643,11 +642,7 @@ size_query_box_response (GtkWidget *widget, unit, query_box->callback_data); - /* Destroy the box */ - if (query_box->qbox) - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); + query_box_destroy (query_box); } static void @@ -663,21 +658,12 @@ boolean_query_box_response (GtkWidget *widget, GTK_RESPONSE_OK), query_box->callback_data); - /* Destroy the box */ - if (query_box->qbox) - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); + query_box_destroy (query_box); } static void query_box_cancel_callback (QueryBox *query_box) { query_box_disconnect (query_box); - - /* Destroy the box */ - if (query_box->qbox) - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); + query_box_destroy (query_box); } diff --git a/libgimpwidgets/gimpsizeentry.c b/libgimpwidgets/gimpsizeentry.c index 558832e655..c00717a39d 100644 --- a/libgimpwidgets/gimpsizeentry.c +++ b/libgimpwidgets/gimpsizeentry.c @@ -153,7 +153,11 @@ gimp_size_entry_finalize (GObject *object) if (gse->fields) { - g_slist_foreach (gse->fields, (GFunc) g_free, NULL); + GSList *list; + + for (list = gse->fields; list; list = list->next) + g_slice_free (GimpSizeEntryField, list->data); + g_slist_free (gse->fields); gse->fields = NULL; } @@ -252,10 +256,9 @@ gimp_size_entry_new (gint number_of_fields, for (i = 0; i < number_of_fields; i++) { - GimpSizeEntryField *gsef; + GimpSizeEntryField *gsef = g_slice_new0 (GimpSizeEntryField); gint digits; - gsef = g_new0 (GimpSizeEntryField, 1); gse->fields = g_slist_append (gse->fields, gsef); gsef->gse = gse; @@ -375,7 +378,7 @@ gimp_size_entry_add_field (GimpSizeEntry *gse, g_return_if_fail (GTK_IS_SPIN_BUTTON (refval_spinbutton)); } - gsef = g_new0 (GimpSizeEntryField, 1); + gsef = g_slice_new0 (GimpSizeEntryField); gse->fields = g_slist_prepend (gse->fields, gsef); gse->number_of_fields++;