forked from AuroraMiddleware/gtk
GtkTextView: use GSlice
GSlice is better for allocating structs. https://bugzilla.gnome.org/show_bug.cgi?id=733407
This commit is contained in:
parent
b441d3a736
commit
9527205291
@ -409,7 +409,7 @@ _gtk_text_btree_new (GtkTextTagTable *table,
|
|||||||
|
|
||||||
/* Create the tree itself */
|
/* Create the tree itself */
|
||||||
|
|
||||||
tree = g_new0(GtkTextBTree, 1);
|
tree = g_slice_new0 (GtkTextBTree);
|
||||||
tree->root_node = root_node;
|
tree->root_node = root_node;
|
||||||
tree->table = table;
|
tree->table = table;
|
||||||
tree->views = NULL;
|
tree->views = NULL;
|
||||||
@ -527,7 +527,7 @@ _gtk_text_btree_unref (GtkTextBTree *tree)
|
|||||||
g_object_unref (tree->selection_bound_mark);
|
g_object_unref (tree->selection_bound_mark);
|
||||||
tree->selection_bound_mark = NULL;
|
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);
|
g_return_if_fail (tree != NULL);
|
||||||
|
|
||||||
view = g_new (BTreeView, 1);
|
view = g_slice_new (BTreeView);
|
||||||
|
|
||||||
view->view_id = layout;
|
view->view_id = layout;
|
||||||
view->layout = layout;
|
view->layout = layout;
|
||||||
@ -1571,7 +1571,7 @@ _gtk_text_btree_add_view (GtkTextBTree *tree,
|
|||||||
*/
|
*/
|
||||||
last_line = get_last_line (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->view_id = layout;
|
||||||
line_data->next = NULL;
|
line_data->next = NULL;
|
||||||
line_data->width = 0;
|
line_data->width = 0;
|
||||||
@ -1617,14 +1617,14 @@ _gtk_text_btree_remove_view (GtkTextBTree *tree,
|
|||||||
*/
|
*/
|
||||||
last_line = get_last_line (tree);
|
last_line = get_last_line (tree);
|
||||||
line_data = _gtk_text_line_remove_data (last_line, view_id);
|
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);
|
gtk_text_btree_node_remove_view (view, tree->root_node, view_id);
|
||||||
|
|
||||||
view->layout = (gpointer) 0xdeadbeef;
|
view->layout = (gpointer) 0xdeadbeef;
|
||||||
view->view_id = (gpointer) 0xdeadbeef;
|
view->view_id = (gpointer) 0xdeadbeef;
|
||||||
|
|
||||||
g_free (view);
|
g_slice_free (BTreeView, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -3595,7 +3595,7 @@ _gtk_text_line_data_new (GtkTextLayout *layout,
|
|||||||
{
|
{
|
||||||
GtkTextLineData *line_data;
|
GtkTextLineData *line_data;
|
||||||
|
|
||||||
line_data = g_new (GtkTextLineData, 1);
|
line_data = g_slice_new (GtkTextLineData);
|
||||||
|
|
||||||
line_data->view_id = layout;
|
line_data->view_id = layout;
|
||||||
line_data->next = NULL;
|
line_data->next = NULL;
|
||||||
|
@ -1096,7 +1096,7 @@ save_range (GtkTextIter *range_start,
|
|||||||
{
|
{
|
||||||
Range *r;
|
Range *r;
|
||||||
|
|
||||||
r = g_new (Range, 1);
|
r = g_slice_new (Range);
|
||||||
|
|
||||||
r->buffer = gtk_text_iter_get_buffer (range_start);
|
r->buffer = gtk_text_iter_get_buffer (range_start);
|
||||||
g_object_ref (r->buffer);
|
g_object_ref (r->buffer);
|
||||||
@ -1156,7 +1156,7 @@ restore_range (Range *r)
|
|||||||
*r->range_end = *r->whole_end;
|
*r->range_end = *r->whole_end;
|
||||||
|
|
||||||
g_object_unref (r->buffer);
|
g_object_unref (r->buffer);
|
||||||
g_free (r);
|
g_slice_free (Range, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -3354,7 +3354,7 @@ static void
|
|||||||
free_clipboard_request (ClipboardRequest *request_data)
|
free_clipboard_request (ClipboardRequest *request_data)
|
||||||
{
|
{
|
||||||
g_object_unref (request_data->buffer);
|
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
|
/* Called when we request a paste and receive the text data
|
||||||
@ -3710,7 +3710,7 @@ gtk_text_buffer_add_selection_clipboard (GtkTextBuffer *buffer,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
selection_clipboard = g_new (SelectionClipboard, 1);
|
selection_clipboard = g_slice_new (SelectionClipboard);
|
||||||
|
|
||||||
selection_clipboard->clipboard = clipboard;
|
selection_clipboard->clipboard = clipboard;
|
||||||
selection_clipboard->ref_count = 1;
|
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,
|
buffer->priv->selection_clipboards = g_slist_remove (buffer->priv->selection_clipboards,
|
||||||
selection_clipboard);
|
selection_clipboard);
|
||||||
|
|
||||||
g_free (selection_clipboard);
|
g_slice_free (SelectionClipboard, selection_clipboard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3758,8 +3758,14 @@ static void
|
|||||||
remove_all_selection_clipboards (GtkTextBuffer *buffer)
|
remove_all_selection_clipboards (GtkTextBuffer *buffer)
|
||||||
{
|
{
|
||||||
GtkTextBufferPrivate *priv = buffer->priv;
|
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);
|
g_slist_free (priv->selection_clipboards);
|
||||||
priv->selection_clipboards = NULL;
|
priv->selection_clipboards = NULL;
|
||||||
}
|
}
|
||||||
@ -3785,7 +3791,7 @@ gtk_text_buffer_paste_clipboard (GtkTextBuffer *buffer,
|
|||||||
GtkTextIter *override_location,
|
GtkTextIter *override_location,
|
||||||
gboolean default_editable)
|
gboolean default_editable)
|
||||||
{
|
{
|
||||||
ClipboardRequest *data = g_new (ClipboardRequest, 1);
|
ClipboardRequest *data = g_slice_new (ClipboardRequest);
|
||||||
GtkTextIter paste_point;
|
GtkTextIter paste_point;
|
||||||
GtkTextIter start, end;
|
GtkTextIter start, end;
|
||||||
|
|
||||||
@ -4289,7 +4295,7 @@ free_log_attr_cache (GtkTextLogAttrCache *cache)
|
|||||||
g_free (cache->entries[i].attrs);
|
g_free (cache->entries[i].attrs);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
g_free (cache);
|
g_slice_free (GtkTextLogAttrCache, cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -4376,7 +4382,7 @@ _gtk_text_buffer_get_line_log_attrs (GtkTextBuffer *buffer,
|
|||||||
|
|
||||||
if (priv->log_attr_cache == NULL)
|
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 =
|
priv->log_attr_cache->chars_changed_stamp =
|
||||||
_gtk_text_btree_get_chars_changed_stamp (get_btree (buffer));
|
_gtk_text_btree_get_chars_changed_stamp (get_btree (buffer));
|
||||||
}
|
}
|
||||||
|
@ -728,7 +728,7 @@ register_format (GList *formats,
|
|||||||
|
|
||||||
formats = unregister_format (formats, *atom);
|
formats = unregister_format (formats, *atom);
|
||||||
|
|
||||||
format = g_new0 (GtkRichTextFormat, 1);
|
format = g_slice_new0 (GtkRichTextFormat);
|
||||||
|
|
||||||
format->mime_type = g_strdup (mime_type);
|
format->mime_type = g_strdup (mime_type);
|
||||||
format->can_create_tags = FALSE;
|
format->can_create_tags = FALSE;
|
||||||
@ -789,7 +789,7 @@ free_format (GtkRichTextFormat *format)
|
|||||||
format->user_data_destroy (format->user_data);
|
format->user_data_destroy (format->user_data);
|
||||||
|
|
||||||
g_free (format->mime_type);
|
g_free (format->mime_type);
|
||||||
g_free (format);
|
g_slice_free (GtkRichTextFormat, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1140,7 +1140,7 @@ parse_apply_tag_element (GMarkupParseContext *context,
|
|||||||
int_id = atoi (pixbuf_id);
|
int_id = atoi (pixbuf_id);
|
||||||
pixbuf = get_pixbuf_from_headers (info->headers, int_id, error);
|
pixbuf = get_pixbuf_from_headers (info->headers, int_id, error);
|
||||||
|
|
||||||
span = g_new0 (TextSpan, 1);
|
span = g_slice_new0 (TextSpan);
|
||||||
span->pixbuf = pixbuf;
|
span->pixbuf = pixbuf;
|
||||||
span->tags = NULL;
|
span->tags = NULL;
|
||||||
|
|
||||||
@ -1505,7 +1505,7 @@ end_element_handler (GMarkupParseContext *context,
|
|||||||
TextTagPrio *prio;
|
TextTagPrio *prio;
|
||||||
|
|
||||||
/* add the tag to the list */
|
/* add the tag to the list */
|
||||||
prio = g_new0 (TextTagPrio, 1);
|
prio = g_slice_new0 (TextTagPrio);
|
||||||
prio->prio = info->current_tag_prio;
|
prio->prio = info->current_tag_prio;
|
||||||
prio->tag = info->current_tag;
|
prio->tag = info->current_tag;
|
||||||
|
|
||||||
@ -1596,7 +1596,7 @@ text_handler (GMarkupParseContext *context,
|
|||||||
if (text_len == 0)
|
if (text_len == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
span = g_new0 (TextSpan, 1);
|
span = g_slice_new0 (TextSpan);
|
||||||
span->text = g_strndup (text, text_len);
|
span->text = g_strndup (text, text_len);
|
||||||
span->tags = g_slist_copy (info->tag_stack);
|
span->tags = g_slist_copy (info->tag_stack);
|
||||||
|
|
||||||
@ -1637,7 +1637,7 @@ text_span_free (TextSpan *span)
|
|||||||
{
|
{
|
||||||
g_free (span->text);
|
g_free (span->text);
|
||||||
g_slist_free (span->tags);
|
g_slist_free (span->tags);
|
||||||
g_free (span);
|
g_slice_free (TextSpan, span);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1670,7 +1670,7 @@ parse_info_free (ParseInfo *info)
|
|||||||
|
|
||||||
if (prio->tag)
|
if (prio->tag)
|
||||||
g_object_unref (prio->tag);
|
g_object_unref (prio->tag);
|
||||||
g_free (prio);
|
g_slice_free (TextTagPrio, prio);
|
||||||
|
|
||||||
list = list->next;
|
list = list->next;
|
||||||
}
|
}
|
||||||
@ -1758,6 +1758,7 @@ read_headers (const gchar *start,
|
|||||||
int section_len;
|
int section_len;
|
||||||
Header *header;
|
Header *header;
|
||||||
GList *headers = NULL;
|
GList *headers = NULL;
|
||||||
|
GList *l;
|
||||||
|
|
||||||
while (i < len)
|
while (i < len)
|
||||||
{
|
{
|
||||||
@ -1772,7 +1773,7 @@ read_headers (const gchar *start,
|
|||||||
if (i + 30 + section_len > len)
|
if (i + 30 + section_len > len)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
header = g_new0 (Header, 1);
|
header = g_slice_new0 (Header);
|
||||||
header->id = start + i;
|
header->id = start + i;
|
||||||
header->length = section_len;
|
header->length = section_len;
|
||||||
header->start = start + i + 30;
|
header->start = start + i + 30;
|
||||||
@ -1788,7 +1789,13 @@ read_headers (const gchar *start,
|
|||||||
return g_list_reverse (headers);
|
return g_list_reverse (headers);
|
||||||
|
|
||||||
error:
|
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_set_error_literal (error,
|
||||||
G_MARKUP_ERROR,
|
G_MARKUP_ERROR,
|
||||||
@ -1857,6 +1864,7 @@ _gtk_text_buffer_deserialize_rich_text (GtkTextBuffer *register_buffer,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GList *headers;
|
GList *headers;
|
||||||
|
GList *l;
|
||||||
Header *header;
|
Header *header;
|
||||||
gboolean retval;
|
gboolean retval;
|
||||||
|
|
||||||
@ -1882,7 +1890,13 @@ _gtk_text_buffer_deserialize_rich_text (GtkTextBuffer *register_buffer,
|
|||||||
create_tags, error, headers->next);
|
create_tags, error, headers->next);
|
||||||
|
|
||||||
out:
|
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;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -964,7 +964,7 @@ gtk_text_layout_real_free_line_data (GtkTextLayout *layout,
|
|||||||
{
|
{
|
||||||
gtk_text_layout_invalidate_cache (layout, line, FALSE);
|
gtk_text_layout_invalidate_cache (layout, line, FALSE);
|
||||||
|
|
||||||
g_free (line_data);
|
g_slice_free (GtkTextLineData, line_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2222,7 +2222,7 @@ free_pending_scroll (GtkTextPendingScroll *scroll)
|
|||||||
gtk_text_buffer_delete_mark (gtk_text_mark_get_buffer (scroll->mark),
|
gtk_text_buffer_delete_mark (gtk_text_mark_get_buffer (scroll->mark),
|
||||||
scroll->mark);
|
scroll->mark);
|
||||||
g_object_unref (scroll->mark);
|
g_object_unref (scroll->mark);
|
||||||
g_free (scroll);
|
g_slice_free (GtkTextPendingScroll, scroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2248,7 +2248,7 @@ gtk_text_view_queue_scroll (GtkTextView *text_view,
|
|||||||
|
|
||||||
DV(g_print(G_STRLOC"\n"));
|
DV(g_print(G_STRLOC"\n"));
|
||||||
|
|
||||||
scroll = g_new (GtkTextPendingScroll, 1);
|
scroll = g_slice_new (GtkTextPendingScroll);
|
||||||
|
|
||||||
scroll->within_margin = within_margin;
|
scroll->within_margin = within_margin;
|
||||||
scroll->use_align = use_align;
|
scroll->use_align = use_align;
|
||||||
@ -6923,7 +6923,7 @@ selection_data_free (SelectionData *data)
|
|||||||
if (data->orig_end != NULL)
|
if (data->orig_end != NULL)
|
||||||
gtk_text_buffer_delete_mark (gtk_text_mark_get_buffer (data->orig_end),
|
gtk_text_buffer_delete_mark (gtk_text_mark_get_buffer (data->orig_end),
|
||||||
data->orig_end);
|
data->orig_end);
|
||||||
g_free (data);
|
g_slice_free (SelectionData, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -7147,7 +7147,7 @@ gtk_text_view_start_selection_drag (GtkTextView *text_view,
|
|||||||
GdkModifierType state;
|
GdkModifierType state;
|
||||||
|
|
||||||
priv = text_view->priv;
|
priv = text_view->priv;
|
||||||
data = g_new0 (SelectionData, 1);
|
data = g_slice_new0 (SelectionData);
|
||||||
data->granularity = granularity;
|
data->granularity = granularity;
|
||||||
|
|
||||||
buffer = get_buffer (text_view);
|
buffer = get_buffer (text_view);
|
||||||
@ -8878,14 +8878,14 @@ popup_targets_received (GtkClipboard *clipboard,
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (text_view);
|
g_object_unref (text_view);
|
||||||
g_free (info);
|
g_slice_free (PopupInfo, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_view_do_popup (GtkTextView *text_view,
|
gtk_text_view_do_popup (GtkTextView *text_view,
|
||||||
const GdkEvent *event)
|
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
|
/* In order to know what entries we should make sensitive, we
|
||||||
* ask for the current targets of the clipboard, and when
|
* ask for the current targets of the clipboard, and when
|
||||||
@ -9099,7 +9099,7 @@ text_window_new (GtkTextWindowType type,
|
|||||||
{
|
{
|
||||||
GtkTextWindow *win;
|
GtkTextWindow *win;
|
||||||
|
|
||||||
win = g_new (GtkTextWindow, 1);
|
win = g_slice_new (GtkTextWindow);
|
||||||
|
|
||||||
win->type = type;
|
win->type = type;
|
||||||
win->widget = widget;
|
win->widget = widget;
|
||||||
@ -9121,7 +9121,7 @@ text_window_free (GtkTextWindow *win)
|
|||||||
if (win->window)
|
if (win->window)
|
||||||
text_window_unrealize (win);
|
text_window_unrealize (win);
|
||||||
|
|
||||||
g_free (win);
|
g_slice_free (GtkTextWindow, win);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -10065,7 +10065,7 @@ text_view_child_new_anchored (GtkWidget *child,
|
|||||||
{
|
{
|
||||||
GtkTextViewChild *vc;
|
GtkTextViewChild *vc;
|
||||||
|
|
||||||
vc = g_new (GtkTextViewChild, 1);
|
vc = g_slice_new (GtkTextViewChild);
|
||||||
|
|
||||||
vc->type = GTK_TEXT_WINDOW_PRIVATE;
|
vc->type = GTK_TEXT_WINDOW_PRIVATE;
|
||||||
vc->widget = child;
|
vc->widget = child;
|
||||||
@ -10094,7 +10094,7 @@ text_view_child_new_window (GtkWidget *child,
|
|||||||
{
|
{
|
||||||
GtkTextViewChild *vc;
|
GtkTextViewChild *vc;
|
||||||
|
|
||||||
vc = g_new (GtkTextViewChild, 1);
|
vc = g_slice_new (GtkTextViewChild);
|
||||||
|
|
||||||
vc->widget = child;
|
vc->widget = child;
|
||||||
vc->anchor = NULL;
|
vc->anchor = NULL;
|
||||||
@ -10130,7 +10130,7 @@ text_view_child_free (GtkTextViewChild *child)
|
|||||||
|
|
||||||
g_object_unref (child->widget);
|
g_object_unref (child->widget);
|
||||||
|
|
||||||
g_free (child);
|
g_slice_free (GtkTextViewChild, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user