Use GSlice for GtkRequisition

Also add gtk_requisition_new to avoid memory allocator confusions when
using GtkRequisitions.

Based on a Christian Persch patch.
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=461618
This commit is contained in:
Javier Jardón 2010-05-04 05:27:50 +02:00
parent bcbb976d91
commit eaab96c066
4 changed files with 21 additions and 2 deletions

View File

@ -4942,6 +4942,7 @@ gtk_widget_get_requisition
gtk_widget_device_is_shadowed
<SUBSECTION>
gtk_requisition_new
gtk_requisition_copy
gtk_requisition_free

View File

@ -4312,6 +4312,7 @@ gtk_vseparator_new
gtk_requisition_copy
gtk_requisition_free
gtk_requisition_get_type G_GNUC_CONST
gtk_requisition_new G_GNUC_MALLOC
gtk_widget_activate
gtk_widget_is_composited
gtk_widget_add_accelerator

View File

@ -10240,6 +10240,22 @@ gtk_widget_class_path (GtkWidget *widget,
}
}
/**
* gtk_requisition_new:
*
* Allocates a new #GtkRequisition structure and initializes its elements to zero.
*
* Returns: a new empty #GtkRequisition. The newly allocated #GtkRequisition should
* be freed with gtk_requisition_free().
*
* Since: 3.0
*/
GtkRequisition *
gtk_requisition_new (void)
{
return g_slice_new0 (GtkRequisition);
}
/**
* gtk_requisition_copy:
* @requisition: a #GtkRequisition
@ -10251,7 +10267,7 @@ gtk_widget_class_path (GtkWidget *widget,
GtkRequisition *
gtk_requisition_copy (const GtkRequisition *requisition)
{
return (GtkRequisition *)g_memdup (requisition, sizeof (GtkRequisition));
return g_slice_dup (GtkRequisition, requisition);
}
/**
@ -10263,7 +10279,7 @@ gtk_requisition_copy (const GtkRequisition *requisition)
void
gtk_requisition_free (GtkRequisition *requisition)
{
g_free (requisition);
g_slice_free (GtkRequisition, requisition);
}
GType

View File

@ -954,6 +954,7 @@ void gtk_widget_set_has_tooltip (GtkWidget *widget,
gboolean gtk_widget_get_has_tooltip (GtkWidget *widget);
GType gtk_requisition_get_type (void) G_GNUC_CONST;
GtkRequisition *gtk_requisition_new (void) G_GNUC_MALLOC;
GtkRequisition *gtk_requisition_copy (const GtkRequisition *requisition);
void gtk_requisition_free (GtkRequisition *requisition);