After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 383557 - Use g_slice for gtk_border_copy/free
Use g_slice for gtk_border_copy/free
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2006-12-07 23:38 UTC by Behdad Esfahbod
Modified: 2006-12-24 09:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
the patch (846 bytes, patch)
2006-12-24 04:10 UTC, Behdad Esfahbod
reviewed Details | Review

Description Behdad Esfahbod 2006-12-07 23:38:02 UTC
/**
 * gtk_border_copy:
 * @border_: a #GtkBorder.
 * @returns: a copy of @border_.
 *
 * Copies a #GtkBorder structure.
 **/
GtkBorder *
gtk_border_copy (const GtkBorder *border)
{
  return (GtkBorder *)g_memdup (border, sizeof (GtkBorder));
}

/**
 * gtk_border_free:
 * @border_: a #GtkBorder.
 * 
 * Frees a #GtkBorder structure.
 **/
void
gtk_border_free (GtkBorder *border)
{
  g_free (border);
}


Looks like can use g_slice.
Comment 1 Matthias Clasen 2006-12-08 03:04:21 UTC
Sounds fine. Do you have a patch.
Comment 2 Behdad Esfahbod 2006-12-24 04:10:34 UTC
Created attachment 78850 [details] [review]
the patch

The patch makes a tiny semantic difference here: that the free function warns if passed NULL.  This is the traditional way that copy/free pairs are done in pango and gtk+.  However, in Pango I've started moving to not warning when NULL is passed to copy/free pairs (on an on-demand basis).  That sometimes makes life a lot easier.  For example, pango_context_get_matrix() may return NULL if no matrix is set.  It makes life a lot easier if you could just pass whatever pango_context_get_matrix() returns to pango_matrix_copy(), and later on pass whatever that returns (that can be NULL) to pango_matrix_free()...
Comment 3 Matthias Clasen 2006-12-24 05:26:12 UTC
Why do you want to change gtk_border_free() to warn on NULL ?
I don't think we should change that now, gtk_border_free() is supported
API.

Other than that, the patch looks fine.
Comment 4 Behdad Esfahbod 2006-12-24 05:30:40 UTC
(In reply to comment #3)
> Why do you want to change gtk_border_free() to warn on NULL ?
> I don't think we should change that now, gtk_border_free() is supported
> API.

Just because other copy/free pairs did that.

> Other than that, the patch looks fine.

Will commit without that part.

Comment 5 Behdad Esfahbod 2006-12-24 05:32:41 UTC
2006-12-24  Behdad Esfahbod  <behdad@gnome.org>

        * gtk/gtkstyle.c (gtk_border_copy), (gtk_border_free): Use gslice for
        GtkBorder (#383557).

Comment 6 Behdad Esfahbod 2006-12-24 09:55:24 UTC
2006-12-24  Behdad Esfahbod  <behdad@gnome.org>

        * gtk/gtkentry.c (_gtk_entry_effective_inner_border):
        Use gtk_border_free when freeing border.

2006-12-24  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkbutton.c (gtk_button_get_props): Use 
        gtk_border_free when freeing borders.