Skip to content

Commit

Permalink
all: Stop using g_slice, fix a leak and remove an obsolete
Browse files Browse the repository at this point in the history
workaround.

g_slice is deprecated as of glib 2.62 and is just a wrapper around
the g_new/g_free family.
  • Loading branch information
mtwebster committed Feb 6, 2024
1 parent 2e392a0 commit 981c9ed
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 92 deletions.
4 changes: 2 additions & 2 deletions libnemo-private/nemo-bookmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ nemo_bookmark_get_current_metadata (NemoBookmark *bookmark)
NemoBookmarkMetadata *
nemo_bookmark_metadata_new (void)
{
NemoBookmarkMetadata *meta = g_slice_new0 (NemoBookmarkMetadata);
NemoBookmarkMetadata *meta = g_new0 (NemoBookmarkMetadata, 1);

return meta;
}
Expand Down Expand Up @@ -873,5 +873,5 @@ nemo_bookmark_metadata_free (NemoBookmarkMetadata *metadata)
g_free (metadata->bookmark_name);
g_strfreev (metadata->emblems);

g_slice_free (NemoBookmarkMetadata, metadata);
g_free (metadata);
}
4 changes: 2 additions & 2 deletions libnemo-private/nemo-clipboard-monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ nemo_clipboard_info_new (GList *files,
{
NemoClipboardInfo *info;

info = g_slice_new0 (NemoClipboardInfo);
info = g_new0 (NemoClipboardInfo, 1);
info->files = nemo_file_list_copy (files);
info->cut = cut;

Expand All @@ -128,7 +128,7 @@ nemo_clipboard_info_free (NemoClipboardInfo *info)
{
nemo_file_list_free (info->files);

g_slice_free (NemoClipboardInfo, info);
g_free (info);
}

static void
Expand Down
12 changes: 6 additions & 6 deletions libnemo-private/nemo-file-operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -4328,13 +4328,13 @@ run_conflict_dialog (CommonJob *job,

g_timer_stop (job->time);

data = g_slice_new0 (ConflictDialogData);
data = g_new0 (ConflictDialogData, 1);
data->parent = job->parent_window;
data->src = src;
data->dest = dest;
data->dest_dir = dest_dir;

resp_data = g_slice_new0 (ConflictResponseData);
resp_data = g_new0 (ConflictResponseData, 1);
resp_data->new_name = NULL;
data->resp_data = resp_data;

Expand All @@ -4345,7 +4345,7 @@ run_conflict_dialog (CommonJob *job,
NULL);
nemo_progress_info_resume (job->progress);

g_slice_free (ConflictDialogData, data);
g_free (data);

g_timer_continue (job->time);

Expand All @@ -4356,7 +4356,7 @@ static void
conflict_response_data_free (ConflictResponseData *data)
{
g_free (data->new_name);
g_slice_free (ConflictResponseData, data);
g_free (data);
}

static GFile *
Expand Down Expand Up @@ -6211,7 +6211,7 @@ callback_for_move_to_trash (GHashTable *debuting_uris,
{
if (data->real_callback)
data->real_callback (debuting_uris, !user_cancelled, data->real_data);
g_slice_free (MoveTrashCBData, data);
g_free (data);
}

void
Expand Down Expand Up @@ -6286,7 +6286,7 @@ nemo_file_operations_copy_move (const GList *item_uris,
if (g_file_has_uri_scheme (dest, "trash")) {
MoveTrashCBData *cb_data;

cb_data = g_slice_new0 (MoveTrashCBData);
cb_data = g_new0 (MoveTrashCBData, 1);
cb_data->real_callback = done_callback;
cb_data->real_data = done_callback_data;

Expand Down
4 changes: 2 additions & 2 deletions libnemo-private/nemo-file-undo-operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ typedef struct {
static void
file_undo_info_op_res_free (gpointer data)
{
g_slice_free (FileUndoInfoOpRes, data);
g_free (data);
}

gboolean
Expand Down Expand Up @@ -279,7 +279,7 @@ file_undo_info_complete_apply (NemoFileUndoInfo *self,
gboolean success,
gboolean user_cancel)
{
FileUndoInfoOpRes *op_res = g_slice_new0 (FileUndoInfoOpRes);
FileUndoInfoOpRes *op_res = g_new0 (FileUndoInfoOpRes, 1);

op_res->user_cancel = user_cancel;
op_res->success = success;
Expand Down
8 changes: 4 additions & 4 deletions libnemo-private/nemo-file-utilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ ensure_dirs_task_ready_cb (GObject *_source,
g_list_free (original_dirs);

g_hash_table_unref (data->original_dirs_hash);
g_slice_free (RestoreFilesData, data);
g_free (data);
}

static void
Expand Down Expand Up @@ -1351,7 +1351,7 @@ restore_files_ensure_parent_directories (GHashTable *original_dirs_hash,
RestoreFilesData *data;
GTask *ensure_dirs_task;

data = g_slice_new0 (RestoreFilesData);
data = g_new0 (RestoreFilesData, 1);
data->parent_window = parent_window;
data->original_dirs_hash = g_hash_table_ref (original_dirs_hash);

Expand Down Expand Up @@ -1417,7 +1417,7 @@ get_types_cb (GObject *source_object,
data->callback ((const char **) types, data->user_data);
}
g_strfreev (types);
g_slice_free (GetContentTypesData, data);
g_free (data);
}

void
Expand All @@ -1444,7 +1444,7 @@ nemo_get_x_content_types_for_mount_async (GMount *mount,
return;
}

data = g_slice_new0 (GetContentTypesData);
data = g_new0 (GetContentTypesData, 1);
data->callback = callback;
data->user_data = user_data;

Expand Down
4 changes: 2 additions & 2 deletions libnemo-private/nemo-icon-container.c
Original file line number Diff line number Diff line change
Expand Up @@ -2781,7 +2781,7 @@ finalize (GObject *object)
g_source_remove (details->a11y_item_action_idle_handler);
}

g_slice_free (NemoViewLayoutConstants, details->view_constants);
g_free (details->view_constants);

g_list_free (details->current_selection);
g_free(details);
Expand Down Expand Up @@ -4920,7 +4920,7 @@ nemo_icon_container_init (NemoIconContainer *container)

details->fixed_text_height = -1;

details->view_constants = g_slice_new0 (NemoViewLayoutConstants);
details->view_constants = g_new0 (NemoViewLayoutConstants, 1);

container->details = details;

Expand Down
9 changes: 4 additions & 5 deletions libnemo-private/nemo-icon-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ nemo_icon_info_free (NemoIconInfo *icon)
}

g_free (icon->icon_name);

g_slice_free (NemoIconInfo, icon);
g_free (icon);
}

NemoIconInfo *
Expand Down Expand Up @@ -106,7 +105,7 @@ nemo_icon_info_create (void)
{
NemoIconInfo *icon;

icon = g_slice_new0 (NemoIconInfo);
icon = g_new0 (NemoIconInfo, 1);

icon->last_use_time = g_get_monotonic_time ();
icon->sole_owner = TRUE;
Expand Down Expand Up @@ -270,7 +269,7 @@ icon_key_new (GIcon *icon, int size)
{
IconKey *key;

key = g_slice_new (IconKey);
key = g_new0 (IconKey, 1);
key->icon = g_object_ref (icon);
key->size = size;

Expand All @@ -281,7 +280,7 @@ static void
icon_key_free (IconKey *key)
{
g_object_unref (key->icon);
g_slice_free (IconKey, key);
g_free (key);
}

NemoIconInfo *
Expand Down
4 changes: 2 additions & 2 deletions libnemo-private/nemo-job-queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ job_finished_cb (NemoJobQueue *self,
self->priv->running_jobs = g_list_remove (self->priv->running_jobs, job);
self->priv->queued_jobs = g_list_remove (self->priv->queued_jobs, job);

g_slice_free (Job, job);
g_free (job);

nemo_job_queue_start_next_job (self);
}
Expand All @@ -189,7 +189,7 @@ nemo_job_queue_add_new_job (NemoJobQueue *self,
return;
}

Job *new_job = g_slice_new0 (Job);
Job *new_job = g_new0 (Job, 1);
new_job->job_func = job_func;
new_job->user_data = user_data;
new_job->cancellable = cancellable;
Expand Down
4 changes: 2 additions & 2 deletions libnemo-private/nemo-search-engine-advanced.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static void
search_helper_free (SearchHelper *helper)
{
g_free (helper->exec_format);
g_slice_free (SearchHelper, helper);
g_free (helper);
}

static GList *
Expand Down Expand Up @@ -220,7 +220,7 @@ process_search_helper_file (const gchar *path)
DEBUG ("Replacing existing nemo search_helper for '%s' with %s based on priority.", mime_type, path);
}

helper = g_slice_new0 (SearchHelper);
helper = g_new0 (SearchHelper, 1);
helper->exec_format = g_strdup (exec_format);
helper->priority = priority;

Expand Down
4 changes: 2 additions & 2 deletions libnemo-private/nemo-search-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ static GHashTable *fsr_accounting_table = NULL;
FileSearchResult *
file_search_result_new (gchar *uri, gchar *snippet)
{
FileSearchResult *ret = g_slice_new0 (FileSearchResult);
FileSearchResult *ret = g_new0 (FileSearchResult, 1);

ret->uri = uri;
ret->snippet = snippet;
Expand Down Expand Up @@ -215,7 +215,7 @@ file_search_result_free (FileSearchResult *res)

g_free (res->uri);
g_free (res->snippet);
g_slice_free (FileSearchResult, res);
g_free (res);
}

void
Expand Down
4 changes: 2 additions & 2 deletions src/nemo-action-config-widget.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ action_proxy_free (ActionProxy *proxy)
g_clear_pointer (&proxy->stock_id, g_free);
g_clear_pointer (&proxy->icon_name, g_free);
g_clear_pointer (&proxy->filename, g_free);
g_slice_free (ActionProxy, proxy);
g_free (proxy);
}

static GtkWidget *
Expand Down Expand Up @@ -114,7 +114,7 @@ make_action_proxy (const gchar *filename, const gchar *fullpath)
}
}

ActionProxy *proxy = g_slice_new0 (ActionProxy);
ActionProxy *proxy = g_new0 (ActionProxy, 1);

gchar *name = g_key_file_get_locale_string (key_file,
ACTION_FILE_GROUP,
Expand Down
4 changes: 2 additions & 2 deletions src/nemo-desktop-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ free_info (DesktopInfo *info)
g_return_if_fail (info != NULL);

g_clear_pointer (&info->window, gtk_widget_destroy);
g_slice_free (DesktopInfo, info);
g_free (info);
}

static RunState
Expand Down Expand Up @@ -308,7 +308,7 @@ create_new_desktop_window (NemoDesktopManager *manager,
FETCH_PRIV (manager);
GtkWidget *window;

DesktopInfo *info = g_slice_new0 (DesktopInfo);
DesktopInfo *info = g_new0 (DesktopInfo, 1);

info->monitor_num = monitor;
info->shows_desktop = show_desktop;
Expand Down
4 changes: 2 additions & 2 deletions src/nemo-extension-config-widget.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extension_proxy_free (ExtensionProxy *proxy)
g_clear_pointer (&proxy->display_name, g_free);
g_clear_pointer (&proxy->desc, g_free);
g_clear_pointer (&proxy->config_exec, g_free);
g_slice_free (ExtensionProxy, proxy);
g_free (proxy);
}

static void
Expand Down Expand Up @@ -160,7 +160,7 @@ detect_extensions (NemoExtensionConfigWidget *widget)
guint i;
for (i = 0; i < g_strv_length (lines); i++) {
if (g_str_has_prefix (lines[i], LINE_PREFIX)) {
ExtensionProxy *p = g_slice_new0 (ExtensionProxy);
ExtensionProxy *p = g_new0 (ExtensionProxy, 1);

gchar **split = g_strsplit (lines[i] + LINE_PREFIX_LEN, ":::", -1);
gint len = g_strv_length (split);
Expand Down
4 changes: 2 additions & 2 deletions src/nemo-places-sidebar.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ new_place_info (PlaceType place_type,
gint df_percent,
gboolean show_df_percent)
{
PlaceInfo *info = g_slice_new0 (PlaceInfo);
PlaceInfo *info = g_new0 (PlaceInfo, 1);

info->place_type = place_type;
info->section_type = section_type;
Expand Down Expand Up @@ -433,7 +433,7 @@ free_place_info (PlaceInfo *info)
g_clear_object (&info->mount);
g_free (info->tooltip);

g_slice_free (PlaceInfo, info);
g_free (info);
}

static GtkTreeIter
Expand Down
4 changes: 2 additions & 2 deletions src/nemo-progress-ui-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ timeout_data_free (TimeoutData *data)
g_clear_object (&data->self);
g_clear_object (&data->info);

g_slice_free (TimeoutData, data);
g_free (data);
}

static TimeoutData *
Expand All @@ -394,7 +394,7 @@ timeout_data_new (NemoProgressUIHandler *self,
{
TimeoutData *retval;

retval = g_slice_new0 (TimeoutData);
retval = g_new0 (TimeoutData, 1);
retval->self = g_object_ref (self);
retval->info = g_object_ref (info);

Expand Down
5 changes: 3 additions & 2 deletions src/nemo-script-config-widget.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ typedef struct {
static void
script_proxy_free (ScriptProxy *proxy)
{
g_clear_pointer (&proxy->name, g_free);
g_free (proxy->name);
g_free (proxy);
}

static GtkWidget *
Expand Down Expand Up @@ -113,7 +114,7 @@ populate_from_directory (NemoScriptConfigWidget *widget, const gchar *path)
continue;
}

ScriptProxy *p = g_slice_new0 (ScriptProxy);
ScriptProxy *p = g_new0 (ScriptProxy, 1);
p->name = g_strdup (name);
p->widget = widget;

Expand Down
4 changes: 2 additions & 2 deletions src/nemo-view-dnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ handle_netscape_url_drop_link_cb (GObject *source_object,
g_free (data->target_uri);

g_object_unref (data->view);
g_slice_free (NetscapeUrlDropLink, data);
g_free (data);
}

void
Expand Down Expand Up @@ -220,7 +220,7 @@ nemo_view_handle_netscape_url_drop (NemoView *view,
if (g_strcmp0 (link_name, NULL) != 0) {
NetscapeUrlDropLink *data;

data = g_slice_new0 (NetscapeUrlDropLink);
data = g_new0 (NetscapeUrlDropLink, 1);
data->link_name = link_name;
data->point.x = x;
data->point.y = y;
Expand Down
4 changes: 2 additions & 2 deletions src/nemo-window-slot-dnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ drag_info_free (gpointer user_data)
g_clear_object (&drag_info->target_slot);
g_clear_pointer (&drag_info->desktop_dnd_source_fs, g_free);

g_slice_free (NemoDragSlotProxyInfo, drag_info);
g_free (drag_info);
}

static void
Expand Down Expand Up @@ -332,7 +332,7 @@ nemo_drag_slot_proxy_init (GtkWidget *widget,

g_assert (GTK_IS_WIDGET (widget));

drag_info = g_slice_new0 (NemoDragSlotProxyInfo);
drag_info = g_new0 (NemoDragSlotProxyInfo, 1);

g_object_set_data_full (G_OBJECT (widget), "drag-slot-proxy-data", drag_info,
drag_info_free);
Expand Down
Loading

0 comments on commit 981c9ed

Please sign in to comment.