libgimpwidgets/gimpsizeentry.c allocate structs using GSlice.

2007-05-22  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/gimpsizeentry.c
	* libgimpwidgets/gimpquerybox.c: allocate structs using GSlice.

svn path=/trunk/; revision=22562
This commit is contained in:
Sven Neumann 2007-05-22 11:49:24 +00:00 committed by Sven Neumann
parent 65f80e1825
commit 16ec38275c
3 changed files with 30 additions and 36 deletions

View File

@ -1,3 +1,8 @@
2007-05-22 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpsizeentry.c
* libgimpwidgets/gimpquerybox.c: allocate structs using GSlice.
2007-05-22 Sven Neumann <sven@gimp.org> 2007-05-22 Sven Neumann <sven@gimp.org>
* libgimpconfig/gimpconfigwriter.c: use GSlice for the * libgimpconfig/gimpconfigwriter.c: use GSlice for the

View File

@ -70,6 +70,7 @@ static QueryBox * create_query_box (const gchar *title,
gpointer callback_data); gpointer callback_data);
static void query_box_disconnect (QueryBox *query_box); static void query_box_disconnect (QueryBox *query_box);
static void query_box_destroy (QueryBox *query_box);
static void string_query_box_response (GtkWidget *widget, static void string_query_box_response (GtkWidget *widget,
gint response_id, 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 || G_IS_OBJECT (object), NULL);
g_return_val_if_fail (object == NULL || signal != NULL, 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", query_box->qbox = gimp_dialog_new (title, "gimp-query-box",
parent, 0, parent, 0,
@ -547,6 +548,16 @@ query_box_disconnect (QueryBox *query_box)
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 static void
string_query_box_response (GtkWidget *widget, string_query_box_response (GtkWidget *widget,
gint response_id, gint response_id,
@ -565,11 +576,7 @@ string_query_box_response (GtkWidget *widget,
string, string,
query_box->callback_data); query_box->callback_data);
/* Destroy the box */ query_box_destroy (query_box);
if (query_box->qbox)
gtk_widget_destroy (query_box->qbox);
g_free (query_box);
} }
static void static void
@ -590,11 +597,7 @@ int_query_box_response (GtkWidget *widget,
value, value,
query_box->callback_data); query_box->callback_data);
/* Destroy the box */ query_box_destroy (query_box);
if (query_box->qbox)
gtk_widget_destroy (query_box->qbox);
g_free (query_box);
} }
static void static void
@ -615,11 +618,7 @@ double_query_box_response (GtkWidget *widget,
value, value,
query_box->callback_data); query_box->callback_data);
/* Destroy the box */ query_box_destroy (query_box);
if (query_box->qbox)
gtk_widget_destroy (query_box->qbox);
g_free (query_box);
} }
static void static void
@ -643,11 +642,7 @@ size_query_box_response (GtkWidget *widget,
unit, unit,
query_box->callback_data); query_box->callback_data);
/* Destroy the box */ query_box_destroy (query_box);
if (query_box->qbox)
gtk_widget_destroy (query_box->qbox);
g_free (query_box);
} }
static void static void
@ -663,21 +658,12 @@ boolean_query_box_response (GtkWidget *widget,
GTK_RESPONSE_OK), GTK_RESPONSE_OK),
query_box->callback_data); query_box->callback_data);
/* Destroy the box */ query_box_destroy (query_box);
if (query_box->qbox)
gtk_widget_destroy (query_box->qbox);
g_free (query_box);
} }
static void static void
query_box_cancel_callback (QueryBox *query_box) query_box_cancel_callback (QueryBox *query_box)
{ {
query_box_disconnect (query_box); query_box_disconnect (query_box);
query_box_destroy (query_box);
/* Destroy the box */
if (query_box->qbox)
gtk_widget_destroy (query_box->qbox);
g_free (query_box);
} }

View File

@ -153,7 +153,11 @@ gimp_size_entry_finalize (GObject *object)
if (gse->fields) 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); g_slist_free (gse->fields);
gse->fields = NULL; gse->fields = NULL;
} }
@ -252,10 +256,9 @@ gimp_size_entry_new (gint number_of_fields,
for (i = 0; i < number_of_fields; i++) for (i = 0; i < number_of_fields; i++)
{ {
GimpSizeEntryField *gsef; GimpSizeEntryField *gsef = g_slice_new0 (GimpSizeEntryField);
gint digits; gint digits;
gsef = g_new0 (GimpSizeEntryField, 1);
gse->fields = g_slist_append (gse->fields, gsef); gse->fields = g_slist_append (gse->fields, gsef);
gsef->gse = gse; gsef->gse = gse;
@ -375,7 +378,7 @@ gimp_size_entry_add_field (GimpSizeEntry *gse,
g_return_if_fail (GTK_IS_SPIN_BUTTON (refval_spinbutton)); 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->fields = g_slist_prepend (gse->fields, gsef);
gse->number_of_fields++; gse->number_of_fields++;