diff options
author | Sébastien Wilmet <swilmet@gnome.org> | 2014-04-11 17:45:50 +0200 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-04-13 14:04:12 -0700 |
commit | 983a03d5f85f4e10f5392df2fd2de0c0bf670f7d (patch) | |
tree | bcfda4f1b7553c5f0f40b4c5a6d76ec9e8615b2d /gtk/gtktextmark.c | |
parent | d69d57afa7d1966ab5ebc26bfe9eb1b24ba01571 (diff) | |
download | gtk+-983a03d5f85f4e10f5392df2fd2de0c0bf670f7d.tar.gz |
GtkTextView: use GSlice to allocate GtkTextLineSegment's
Use GSlice to allocate all types of segments:
- char
- toggle
- mark
- pixbuf
- child widget
Char segments are a bit more complicated because the length of the text
is determined at run time and stored in the 'byte_count' field. If the
text is long, GSlice will call the system malloc() anyway, so it's
better to always use GSlice for GtkTextLineSegment.
Toggle segments are also freed in gtktextbtree.c, hence the function
_gtk_toggle_segment_free() (for a later commit it would be nice to
rename those functions with the _gtk_text prefix).
https://bugzilla.gnome.org/show_bug.cgi?id=727908
Diffstat (limited to 'gtk/gtktextmark.c')
-rw-r--r-- | gtk/gtktextmark.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/gtk/gtktextmark.c b/gtk/gtktextmark.c index 7a1b7e3334..d79e5322b6 100644 --- a/gtk/gtktextmark.c +++ b/gtk/gtktextmark.c @@ -90,6 +90,11 @@ * Marks are typically created using the gtk_text_buffer_create_mark() function. */ +/* + * Macro that determines the size of a mark segment: + */ +#define MSEG_SIZE ((unsigned) (G_STRUCT_OFFSET (GtkTextLineSegment, body) \ + + sizeof (GtkTextMarkBody))) static void gtk_text_mark_set_property (GObject *object, guint prop_id, @@ -161,7 +166,7 @@ gtk_text_mark_finalize (GObject *obj) "impending"); g_free (seg->body.mark.name); - g_free (seg); + g_slice_free1 (MSEG_SIZE, seg); mark->segment = NULL; } @@ -358,20 +363,12 @@ gtk_text_mark_get_left_gravity (GtkTextMark *mark) return seg->type == >k_text_left_mark_type; } -/* - * Macro that determines the size of a mark segment: - */ - -#define MSEG_SIZE ((unsigned) (G_STRUCT_OFFSET (GtkTextLineSegment, body) \ - + sizeof (GtkTextMarkBody))) - - static GtkTextLineSegment * gtk_mark_segment_new (GtkTextMark *mark_obj) { GtkTextLineSegment *mark; - mark = (GtkTextLineSegment *) g_malloc0 (MSEG_SIZE); + mark = g_slice_alloc0 (MSEG_SIZE); mark->body.mark.name = NULL; mark->type = >k_text_right_mark_type; |