summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/gtktextbtree.c16
-rw-r--r--gtk/gtktextbuffer.c26
-rw-r--r--gtk/gtktextbufferrichtext.c4
-rw-r--r--gtk/gtktextbufferserialize.c30
-rw-r--r--gtk/gtktextlayout.c2
-rw-r--r--gtk/gtktextview.c22
6 files changed, 60 insertions, 40 deletions
diff --git a/gtk/gtktextbtree.c b/gtk/gtktextbtree.c
index 825eb95693..9d94282f3e 100644
--- a/gtk/gtktextbtree.c
+++ b/gtk/gtktextbtree.c
@@ -409,7 +409,7 @@ _gtk_text_btree_new (GtkTextTagTable *table,
/* Create the tree itself */
- tree = g_new0(GtkTextBTree, 1);
+ tree = g_slice_new0 (GtkTextBTree);
tree->root_node = root_node;
tree->table = table;
tree->views = NULL;
@@ -527,7 +527,7 @@ _gtk_text_btree_unref (GtkTextBTree *tree)
g_object_unref (tree->selection_bound_mark);
tree->selection_bound_mark = NULL;
- g_free (tree);
+ g_slice_free (GtkTextBTree, tree);
}
}
@@ -1549,7 +1549,7 @@ _gtk_text_btree_add_view (GtkTextBTree *tree,
g_return_if_fail (tree != NULL);
- view = g_new (BTreeView, 1);
+ view = g_slice_new (BTreeView);
view->view_id = layout;
view->layout = layout;
@@ -1571,7 +1571,7 @@ _gtk_text_btree_add_view (GtkTextBTree *tree,
*/
last_line = get_last_line (tree);
- line_data = g_new (GtkTextLineData, 1);
+ line_data = g_slice_new (GtkTextLineData);
line_data->view_id = layout;
line_data->next = NULL;
line_data->width = 0;
@@ -1617,14 +1617,14 @@ _gtk_text_btree_remove_view (GtkTextBTree *tree,
*/
last_line = get_last_line (tree);
line_data = _gtk_text_line_remove_data (last_line, view_id);
- g_free (line_data);
+ g_slice_free (GtkTextLineData, line_data);
gtk_text_btree_node_remove_view (view, tree->root_node, view_id);
view->layout = (gpointer) 0xdeadbeef;
view->view_id = (gpointer) 0xdeadbeef;
-
- g_free (view);
+
+ g_slice_free (BTreeView, view);
}
void
@@ -3595,7 +3595,7 @@ _gtk_text_line_data_new (GtkTextLayout *layout,
{
GtkTextLineData *line_data;
- line_data = g_new (GtkTextLineData, 1);
+ line_data = g_slice_new (GtkTextLineData);
line_data->view_id = layout;
line_data->next = NULL;
diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c
index 10d41d4d6c..0af7cf7e90 100644
--- a/gtk/gtktextbuffer.c
+++ b/gtk/gtktextbuffer.c
@@ -1096,7 +1096,7 @@ save_range (GtkTextIter *range_start,
{
Range *r;
- r = g_new (Range, 1);
+ r = g_slice_new (Range);
r->buffer = gtk_text_iter_get_buffer (range_start);
g_object_ref (r->buffer);
@@ -1156,7 +1156,7 @@ restore_range (Range *r)
*r->range_end = *r->whole_end;
g_object_unref (r->buffer);
- g_free (r);
+ g_slice_free (Range, r);
}
static void
@@ -3354,7 +3354,7 @@ static void
free_clipboard_request (ClipboardRequest *request_data)
{
g_object_unref (request_data->buffer);
- g_free (request_data);
+ g_slice_free (ClipboardRequest, request_data);
}
/* Called when we request a paste and receive the text data
@@ -3710,7 +3710,7 @@ gtk_text_buffer_add_selection_clipboard (GtkTextBuffer *buffer,
}
else
{
- selection_clipboard = g_new (SelectionClipboard, 1);
+ selection_clipboard = g_slice_new (SelectionClipboard);
selection_clipboard->clipboard = clipboard;
selection_clipboard->ref_count = 1;
@@ -3749,8 +3749,8 @@ gtk_text_buffer_remove_selection_clipboard (GtkTextBuffer *buffer,
buffer->priv->selection_clipboards = g_slist_remove (buffer->priv->selection_clipboards,
selection_clipboard);
-
- g_free (selection_clipboard);
+
+ g_slice_free (SelectionClipboard, selection_clipboard);
}
}
@@ -3758,8 +3758,14 @@ static void
remove_all_selection_clipboards (GtkTextBuffer *buffer)
{
GtkTextBufferPrivate *priv = buffer->priv;
+ GSList *l;
+
+ for (l = priv->selection_clipboards; l != NULL; l = l->next)
+ {
+ SelectionClipboard *selection_clipboard = l->data;
+ g_slice_free (SelectionClipboard, selection_clipboard);
+ }
- g_slist_foreach (priv->selection_clipboards, (GFunc)g_free, NULL);
g_slist_free (priv->selection_clipboards);
priv->selection_clipboards = NULL;
}
@@ -3785,7 +3791,7 @@ gtk_text_buffer_paste_clipboard (GtkTextBuffer *buffer,
GtkTextIter *override_location,
gboolean default_editable)
{
- ClipboardRequest *data = g_new (ClipboardRequest, 1);
+ ClipboardRequest *data = g_slice_new (ClipboardRequest);
GtkTextIter paste_point;
GtkTextIter start, end;
@@ -4289,7 +4295,7 @@ free_log_attr_cache (GtkTextLogAttrCache *cache)
g_free (cache->entries[i].attrs);
++i;
}
- g_free (cache);
+ g_slice_free (GtkTextLogAttrCache, cache);
}
static void
@@ -4376,7 +4382,7 @@ _gtk_text_buffer_get_line_log_attrs (GtkTextBuffer *buffer,
if (priv->log_attr_cache == NULL)
{
- priv->log_attr_cache = g_new0 (GtkTextLogAttrCache, 1);
+ priv->log_attr_cache = g_slice_new0 (GtkTextLogAttrCache);
priv->log_attr_cache->chars_changed_stamp =
_gtk_text_btree_get_chars_changed_stamp (get_btree (buffer));
}
diff --git a/gtk/gtktextbufferrichtext.c b/gtk/gtktextbufferrichtext.c
index 4a89b7c75a..c888a98cf4 100644
--- a/gtk/gtktextbufferrichtext.c
+++ b/gtk/gtktextbufferrichtext.c
@@ -728,7 +728,7 @@ register_format (GList *formats,
formats = unregister_format (formats, *atom);
- format = g_new0 (GtkRichTextFormat, 1);
+ format = g_slice_new0 (GtkRichTextFormat);
format->mime_type = g_strdup (mime_type);
format->can_create_tags = FALSE;
@@ -789,7 +789,7 @@ free_format (GtkRichTextFormat *format)
format->user_data_destroy (format->user_data);
g_free (format->mime_type);
- g_free (format);
+ g_slice_free (GtkRichTextFormat, format);
}
static void
diff --git a/gtk/gtktextbufferserialize.c b/gtk/gtktextbufferserialize.c
index 3b77074192..e065f109ef 100644
--- a/gtk/gtktextbufferserialize.c
+++ b/gtk/gtktextbufferserialize.c
@@ -1140,7 +1140,7 @@ parse_apply_tag_element (GMarkupParseContext *context,
int_id = atoi (pixbuf_id);
pixbuf = get_pixbuf_from_headers (info->headers, int_id, error);
- span = g_new0 (TextSpan, 1);
+ span = g_slice_new0 (TextSpan);
span->pixbuf = pixbuf;
span->tags = NULL;
@@ -1505,7 +1505,7 @@ end_element_handler (GMarkupParseContext *context,
TextTagPrio *prio;
/* add the tag to the list */
- prio = g_new0 (TextTagPrio, 1);
+ prio = g_slice_new0 (TextTagPrio);
prio->prio = info->current_tag_prio;
prio->tag = info->current_tag;
@@ -1596,7 +1596,7 @@ text_handler (GMarkupParseContext *context,
if (text_len == 0)
return;
- span = g_new0 (TextSpan, 1);
+ span = g_slice_new0 (TextSpan);
span->text = g_strndup (text, text_len);
span->tags = g_slist_copy (info->tag_stack);
@@ -1637,7 +1637,7 @@ text_span_free (TextSpan *span)
{
g_free (span->text);
g_slist_free (span->tags);
- g_free (span);
+ g_slice_free (TextSpan, span);
}
static void
@@ -1670,7 +1670,7 @@ parse_info_free (ParseInfo *info)
if (prio->tag)
g_object_unref (prio->tag);
- g_free (prio);
+ g_slice_free (TextTagPrio, prio);
list = list->next;
}
@@ -1758,6 +1758,7 @@ read_headers (const gchar *start,
int section_len;
Header *header;
GList *headers = NULL;
+ GList *l;
while (i < len)
{
@@ -1772,7 +1773,7 @@ read_headers (const gchar *start,
if (i + 30 + section_len > len)
goto error;
- header = g_new0 (Header, 1);
+ header = g_slice_new0 (Header);
header->id = start + i;
header->length = section_len;
header->start = start + i + 30;
@@ -1788,7 +1789,13 @@ read_headers (const gchar *start,
return g_list_reverse (headers);
error:
- g_list_free_full (headers, g_free);
+ for (l = headers; l != NULL; l = l->next)
+ {
+ header = l->data;
+ g_slice_free (Header, header);
+ }
+
+ g_list_free (headers);
g_set_error_literal (error,
G_MARKUP_ERROR,
@@ -1857,6 +1864,7 @@ _gtk_text_buffer_deserialize_rich_text (GtkTextBuffer *register_buffer,
GError **error)
{
GList *headers;
+ GList *l;
Header *header;
gboolean retval;
@@ -1882,7 +1890,13 @@ _gtk_text_buffer_deserialize_rich_text (GtkTextBuffer *register_buffer,
create_tags, error, headers->next);
out:
- g_list_free_full (headers, g_free);
+ for (l = headers; l != NULL; l = l->next)
+ {
+ header = l->data;
+ g_slice_free (Header, header);
+ }
+
+ g_list_free (headers);
return retval;
}
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index 99909288f0..7dbb62e13b 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -964,7 +964,7 @@ gtk_text_layout_real_free_line_data (GtkTextLayout *layout,
{
gtk_text_layout_invalidate_cache (layout, line, FALSE);
- g_free (line_data);
+ g_slice_free (GtkTextLineData, line_data);
}
/**
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 75c6f9b5c5..2fba210a30 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -2222,7 +2222,7 @@ free_pending_scroll (GtkTextPendingScroll *scroll)
gtk_text_buffer_delete_mark (gtk_text_mark_get_buffer (scroll->mark),
scroll->mark);
g_object_unref (scroll->mark);
- g_free (scroll);
+ g_slice_free (GtkTextPendingScroll, scroll);
}
static void
@@ -2248,7 +2248,7 @@ gtk_text_view_queue_scroll (GtkTextView *text_view,
DV(g_print(G_STRLOC"\n"));
- scroll = g_new (GtkTextPendingScroll, 1);
+ scroll = g_slice_new (GtkTextPendingScroll);
scroll->within_margin = within_margin;
scroll->use_align = use_align;
@@ -6923,7 +6923,7 @@ selection_data_free (SelectionData *data)
if (data->orig_end != NULL)
gtk_text_buffer_delete_mark (gtk_text_mark_get_buffer (data->orig_end),
data->orig_end);
- g_free (data);
+ g_slice_free (SelectionData, data);
}
static gboolean
@@ -7147,7 +7147,7 @@ gtk_text_view_start_selection_drag (GtkTextView *text_view,
GdkModifierType state;
priv = text_view->priv;
- data = g_new0 (SelectionData, 1);
+ data = g_slice_new0 (SelectionData);
data->granularity = granularity;
buffer = get_buffer (text_view);
@@ -8878,14 +8878,14 @@ popup_targets_received (GtkClipboard *clipboard,
}
g_object_unref (text_view);
- g_free (info);
+ g_slice_free (PopupInfo, info);
}
static void
gtk_text_view_do_popup (GtkTextView *text_view,
const GdkEvent *event)
{
- PopupInfo *info = g_new (PopupInfo, 1);
+ PopupInfo *info = g_slice_new (PopupInfo);
/* In order to know what entries we should make sensitive, we
* ask for the current targets of the clipboard, and when
@@ -9099,7 +9099,7 @@ text_window_new (GtkTextWindowType type,
{
GtkTextWindow *win;
- win = g_new (GtkTextWindow, 1);
+ win = g_slice_new (GtkTextWindow);
win->type = type;
win->widget = widget;
@@ -9121,7 +9121,7 @@ text_window_free (GtkTextWindow *win)
if (win->window)
text_window_unrealize (win);
- g_free (win);
+ g_slice_free (GtkTextWindow, win);
}
static void
@@ -10065,7 +10065,7 @@ text_view_child_new_anchored (GtkWidget *child,
{
GtkTextViewChild *vc;
- vc = g_new (GtkTextViewChild, 1);
+ vc = g_slice_new (GtkTextViewChild);
vc->type = GTK_TEXT_WINDOW_PRIVATE;
vc->widget = child;
@@ -10094,7 +10094,7 @@ text_view_child_new_window (GtkWidget *child,
{
GtkTextViewChild *vc;
- vc = g_new (GtkTextViewChild, 1);
+ vc = g_slice_new (GtkTextViewChild);
vc->widget = child;
vc->anchor = NULL;
@@ -10130,7 +10130,7 @@ text_view_child_free (GtkTextViewChild *child)
g_object_unref (child->widget);
- g_free (child);
+ g_slice_free (GtkTextViewChild, child);
}
static void