Use slice allocator instead of g_new when appropriate

a0b15be6fd
This commit is contained in:
JosephMcc 2017-02-13 02:14:07 -08:00
parent ca9321f599
commit a1e94f2777
2 changed files with 23 additions and 17 deletions

View File

@ -2451,7 +2451,7 @@ async_node_free (AsyncNode *async)
{ {
g_object_unref (async->cancellable); g_object_unref (async->cancellable);
g_slist_free (async->original_children); g_slist_free (async->original_children);
g_free (async); g_slice_free (AsyncNode, async);
} }
static void static void
@ -2606,7 +2606,7 @@ model_load_directory (XedFileBrowserStore *model,
dir->cancellable = g_cancellable_new (); dir->cancellable = g_cancellable_new ();
async = g_new (AsyncNode, 1); async = g_slice_new (AsyncNode);
async->dir = dir; async->dir = dir;
async->cancellable = g_object_ref (dir->cancellable); async->cancellable = g_object_ref (dir->cancellable);
async->original_children = g_slist_copy (dir->children); async->original_children = g_slist_copy (dir->children);
@ -3019,7 +3019,7 @@ mount_cb (GFile *file,
g_object_unref (mount_info->virtual_root); g_object_unref (mount_info->virtual_root);
} }
g_free (mount_info); g_slice_free (MountInfo, mount_info);
} }
static XedFileBrowserStoreResult static XedFileBrowserStoreResult
@ -3043,7 +3043,7 @@ model_mount_root (XedFileBrowserStore *model,
/* Try to mount it */ /* Try to mount it */
FILE_BROWSER_NODE_DIR (model->priv->root)->cancellable = g_cancellable_new (); 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->model = model;
mount_info->virtual_root = g_file_dup (virtual_root); mount_info->virtual_root = g_file_dup (virtual_root);
@ -3637,7 +3637,7 @@ async_data_free (AsyncData *data)
data->model->priv->async_handles = g_slist_remove (data->model->priv->async_handles, data); data->model->priv->async_handles = g_slist_remove (data->model->priv->async_handles, data);
} }
g_free (data); g_slice_free (AsyncData, data);
} }
static gboolean static gboolean
@ -3785,7 +3785,7 @@ xed_file_browser_store_delete_all (XedFileBrowserStore *model,
files = g_list_prepend (files, g_object_ref (node->file)); files = g_list_prepend (files, g_object_ref (node->file));
} }
data = g_new (AsyncData, 1); data = g_slice_new (AsyncData);
data->model = model; data->model = model;
data->cancellable = g_cancellable_new (); data->cancellable = g_cancellable_new ();

View File

@ -253,7 +253,7 @@ free_name_icon (gpointer data)
if (item->icon) if (item->icon)
g_object_unref (item->icon); g_object_unref (item->icon);
g_free (item); g_slice_free (NameIcon, item);
} }
static FilterFunc * static FilterFunc *
@ -264,7 +264,7 @@ filter_func_new (XedFileBrowserWidget * obj,
{ {
FilterFunc *result; FilterFunc *result;
result = g_new (FilterFunc, 1); result = g_slice_new (FilterFunc);
result->id = ++obj->priv->filter_id; result->id = ++obj->priv->filter_id;
result->func = func; result->func = func;
@ -282,7 +282,7 @@ location_free (Location * loc)
if (loc->virtual_root) if (loc->virtual_root)
g_object_unref (loc->virtual_root); g_object_unref (loc->virtual_root);
g_free (loc); g_slice_free (Location, loc);
} }
static gboolean static gboolean
@ -329,6 +329,12 @@ cancel_async_operation (XedFileBrowserWidget *widget)
widget->priv->cancellable = NULL; widget->priv->cancellable = NULL;
} }
static void
filter_func_free (FilterFunc *func)
{
g_slice_free (FilterFunc, func);
}
static void static void
xed_file_browser_widget_finalize (GObject * object) xed_file_browser_widget_finalize (GObject * object)
{ {
@ -344,7 +350,7 @@ xed_file_browser_widget_finalize (GObject * object)
g_object_unref (obj->priv->bookmarks_store); g_object_unref (obj->priv->bookmarks_store);
g_object_unref (obj->priv->combo_model); 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); g_slist_free (obj->priv->filter_funcs);
for (loc = obj->priv->locations; loc; loc = loc->next) for (loc = obj->priv->locations; loc; loc = loc->next)
@ -487,7 +493,7 @@ xed_file_browser_widget_class_finalize (XedFileBrowserWidgetClass *klass)
static void static void
add_signal (XedFileBrowserWidget * obj, gpointer object, gulong id) add_signal (XedFileBrowserWidget * obj, gpointer object, gulong id)
{ {
SignalNode *node = g_new (SignalNode, 1); SignalNode *node = g_slice_new (SignalNode);
node->object = G_OBJECT (object); node->object = G_OBJECT (object);
node->id = id; node->id = id;
@ -506,7 +512,7 @@ clear_signals (XedFileBrowserWidget * obj)
node = (SignalNode *) (item->data); node = (SignalNode *) (item->data);
g_signal_handler_disconnect (node->object, node->id); g_signal_handler_disconnect (node->object, node->id);
g_free (item->data); g_slice_free (SignalNode, node);
} }
g_slist_free (obj->priv->signal_pool); g_slist_free (obj->priv->signal_pool);
@ -1078,7 +1084,7 @@ add_bookmark_hash (XedFileBrowserWidget * obj,
XED_FILE_BOOKMARKS_STORE_COLUMN_NAME, XED_FILE_BOOKMARKS_STORE_COLUMN_NAME,
&name, -1); &name, -1);
item = g_new (NameIcon, 1); item = g_slice_new (NameIcon);
item->name = name; item->name = name;
item->icon = pixbuf; item->icon = pixbuf;
@ -1941,7 +1947,7 @@ xed_file_browser_widget_remove_filter (XedFileBrowserWidget * obj,
obj->priv->filter_funcs = obj->priv->filter_funcs =
g_slist_remove_link (obj->priv->filter_funcs, g_slist_remove_link (obj->priv->filter_funcs,
item); item);
g_free (func); filter_func_free (func);
break; break;
} }
} }
@ -2044,7 +2050,7 @@ async_data_new (XedFileBrowserWidget *widget)
{ {
AsyncData *ret; AsyncData *ret;
ret = g_new (AsyncData, 1); ret = g_slice_new (AsyncData);
ret->widget = widget; ret->widget = widget;
cancel_async_operation (widget); cancel_async_operation (widget);
@ -2059,7 +2065,7 @@ static void
async_free (AsyncData *async) async_free (AsyncData *async)
{ {
g_object_unref (async->cancellable); g_object_unref (async->cancellable);
g_free (async); g_slice_free (AsyncData, async);
} }
static void static void
@ -2516,7 +2522,7 @@ on_virtual_root_changed (XedFileBrowserStore * model,
if (obj->priv->current_location) if (obj->priv->current_location)
clear_next_locations (obj); clear_next_locations (obj);
loc = g_new (Location, 1); loc = g_slice_new (Location);
loc->root = xed_file_browser_store_get_root (model); loc->root = xed_file_browser_store_get_root (model);
loc->virtual_root = g_object_ref (location); loc->virtual_root = g_object_ref (location);