[gedit] Use slice allocator instead of g_new when appropriate
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Use slice allocator instead of g_new when appropriate
- Date: Mon, 10 May 2010 19:02:43 +0000 (UTC)
commit a0b15be6fd680afba64bb09b16b1a7b8e6f31dc5
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Mon May 10 21:02:29 2010 +0200
Use slice allocator instead of g_new when appropriate
plugins/filebrowser/gedit-file-browser-store.c | 10 ++++----
plugins/filebrowser/gedit-file-browser-widget.c | 29 ++++++++++++++--------
2 files changed, 23 insertions(+), 16 deletions(-)
---
diff --git a/plugins/filebrowser/gedit-file-browser-store.c b/plugins/filebrowser/gedit-file-browser-store.c
index 922f06e..458ef20 100644
--- a/plugins/filebrowser/gedit-file-browser-store.c
+++ b/plugins/filebrowser/gedit-file-browser-store.c
@@ -2333,7 +2333,7 @@ async_node_free (AsyncNode *async)
{
g_object_unref (async->cancellable);
g_slist_free (async->original_children);
- g_free (async);
+ g_slice_free (AsyncNode, async);
}
static void
@@ -2488,7 +2488,7 @@ model_load_directory (GeditFileBrowserStore *model,
dir->cancellable = g_cancellable_new ();
- async = g_new (AsyncNode, 1);
+ async = g_slice_new (AsyncNode);
async->dir = dir;
async->cancellable = g_object_ref (dir->cancellable);
async->original_children = g_slist_copy (dir->children);
@@ -2882,7 +2882,7 @@ mount_cb (GFile *file,
g_object_unref (mount_info->virtual_root);
}
- g_free (mount_info);
+ g_slice_free (MountInfo, mount_info);
}
static GeditFileBrowserStoreResult
@@ -2906,7 +2906,7 @@ model_mount_root (GeditFileBrowserStore *model,
/* Try to mount it */
FILE_BROWSER_NODE_DIR (model->priv->root)->cancellable = g_cancellable_new ();
- mount_info = g_new(MountInfo, 1);
+ mount_info = g_slice_new (MountInfo);
mount_info->model = model;
mount_info->virtual_root = g_file_dup (virtual_root);
@@ -3617,7 +3617,7 @@ gedit_file_browser_store_delete_all (GeditFileBrowserStore *model,
files = g_list_prepend (files, g_object_ref (node->file));
}
- data = g_new (AsyncData, 1);
+ data = g_slice_new (AsyncData);
data->model = model;
data->cancellable = g_cancellable_new ();
diff --git a/plugins/filebrowser/gedit-file-browser-widget.c b/plugins/filebrowser/gedit-file-browser-widget.c
index 88cac2c..9d5c7b9 100644
--- a/plugins/filebrowser/gedit-file-browser-widget.c
+++ b/plugins/filebrowser/gedit-file-browser-widget.c
@@ -252,7 +252,7 @@ free_name_icon (gpointer data)
if (item->icon)
g_object_unref (item->icon);
- g_free (item);
+ g_slice_free (NameIcon, item);
}
static FilterFunc *
@@ -263,7 +263,7 @@ filter_func_new (GeditFileBrowserWidget *obj,
{
FilterFunc *result;
- result = g_new (FilterFunc, 1);
+ result = g_slice_new (FilterFunc);
result->id = ++obj->priv->filter_id;
result->func = func;
@@ -281,7 +281,7 @@ location_free (Location *loc)
if (loc->virtual_root)
g_object_unref (loc->virtual_root);
- g_free (loc);
+ g_slice_free (Location, loc);
}
static gboolean
@@ -333,6 +333,12 @@ cancel_async_operation (GeditFileBrowserWidget *widget)
}
static void
+filter_func_free (FilterFunc *func)
+{
+ g_slice_free (FilterFunc, func);
+}
+
+static void
gedit_file_browser_widget_finalize (GObject *object)
{
GeditFileBrowserWidget *obj = GEDIT_FILE_BROWSER_WIDGET (object);
@@ -347,7 +353,7 @@ gedit_file_browser_widget_finalize (GObject *object)
g_object_unref (obj->priv->bookmarks_store);
g_object_unref (obj->priv->combo_model);
- g_slist_foreach (obj->priv->filter_funcs, (GFunc) g_free, NULL);
+ g_slist_foreach (obj->priv->filter_funcs, (GFunc)filter_func_free, NULL);
g_slist_free (obj->priv->filter_funcs);
for (loc = obj->priv->locations; loc; loc = loc->next)
@@ -486,7 +492,7 @@ add_signal (GeditFileBrowserWidget *obj,
gpointer object,
gulong id)
{
- SignalNode *node = g_new (SignalNode, 1);
+ SignalNode *node = g_slice_new (SignalNode);
node->object = G_OBJECT (object);
node->id = id;
@@ -506,7 +512,7 @@ clear_signals (GeditFileBrowserWidget *obj)
node = (SignalNode *) (item->data);
g_signal_handler_disconnect (node->object, node->id);
- g_free (item->data);
+ g_slice_free (SignalNode, node);
}
g_slist_free (obj->priv->signal_pool);
@@ -1104,7 +1110,7 @@ add_bookmark_hash (GeditFileBrowserWidget *obj,
GEDIT_FILE_BOOKMARKS_STORE_COLUMN_NAME,
&name, -1);
- item = g_new (NameIcon, 1);
+ item = g_slice_new (NameIcon);
item->name = name;
item->icon = pixbuf;
@@ -2009,7 +2015,8 @@ gedit_file_browser_widget_remove_filter (GeditFileBrowserWidget *obj,
obj->priv->filter_funcs =
g_slist_remove_link (obj->priv->filter_funcs,
item);
- g_free (func);
+
+ filter_func_free (func);
break;
}
}
@@ -2116,7 +2123,7 @@ async_data_new (GeditFileBrowserWidget *widget)
{
AsyncData *ret;
- ret = g_new (AsyncData, 1);
+ ret = g_slice_new (AsyncData);
ret->widget = widget;
cancel_async_operation (widget);
@@ -2131,7 +2138,7 @@ static void
async_free (AsyncData *async)
{
g_object_unref (async->cancellable);
- g_free (async);
+ g_slice_free (AsyncData, async);
}
static void
@@ -2606,7 +2613,7 @@ on_virtual_root_changed (GeditFileBrowserStore *model,
if (obj->priv->current_location)
clear_next_locations (obj);
- loc = g_new (Location, 1);
+ loc = g_slice_new (Location);
loc->root = gedit_file_browser_store_get_root (model);
loc->virtual_root = g_object_ref (location);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]