Skip to content

Commit 981c9ed

Browse files
committed
all: Stop using g_slice, fix a leak and remove an obsolete
workaround. g_slice is deprecated as of glib 2.62 and is just a wrapper around the g_new/g_free family.
1 parent 2e392a0 commit 981c9ed

20 files changed

Lines changed: 51 additions & 92 deletions

libnemo-private/nemo-bookmark.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ nemo_bookmark_get_current_metadata (NemoBookmark *bookmark)
829829
NemoBookmarkMetadata *
830830
nemo_bookmark_metadata_new (void)
831831
{
832-
NemoBookmarkMetadata *meta = g_slice_new0 (NemoBookmarkMetadata);
832+
NemoBookmarkMetadata *meta = g_new0 (NemoBookmarkMetadata, 1);
833833

834834
return meta;
835835
}
@@ -873,5 +873,5 @@ nemo_bookmark_metadata_free (NemoBookmarkMetadata *metadata)
873873
g_free (metadata->bookmark_name);
874874
g_strfreev (metadata->emblems);
875875

876-
g_slice_free (NemoBookmarkMetadata, metadata);
876+
g_free (metadata);
877877
}

libnemo-private/nemo-clipboard-monitor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ nemo_clipboard_info_new (GList *files,
101101
{
102102
NemoClipboardInfo *info;
103103

104-
info = g_slice_new0 (NemoClipboardInfo);
104+
info = g_new0 (NemoClipboardInfo, 1);
105105
info->files = nemo_file_list_copy (files);
106106
info->cut = cut;
107107

@@ -128,7 +128,7 @@ nemo_clipboard_info_free (NemoClipboardInfo *info)
128128
{
129129
nemo_file_list_free (info->files);
130130

131-
g_slice_free (NemoClipboardInfo, info);
131+
g_free (info);
132132
}
133133

134134
static void

libnemo-private/nemo-file-operations.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4328,13 +4328,13 @@ run_conflict_dialog (CommonJob *job,
43284328

43294329
g_timer_stop (job->time);
43304330

4331-
data = g_slice_new0 (ConflictDialogData);
4331+
data = g_new0 (ConflictDialogData, 1);
43324332
data->parent = job->parent_window;
43334333
data->src = src;
43344334
data->dest = dest;
43354335
data->dest_dir = dest_dir;
43364336

4337-
resp_data = g_slice_new0 (ConflictResponseData);
4337+
resp_data = g_new0 (ConflictResponseData, 1);
43384338
resp_data->new_name = NULL;
43394339
data->resp_data = resp_data;
43404340

@@ -4345,7 +4345,7 @@ run_conflict_dialog (CommonJob *job,
43454345
NULL);
43464346
nemo_progress_info_resume (job->progress);
43474347

4348-
g_slice_free (ConflictDialogData, data);
4348+
g_free (data);
43494349

43504350
g_timer_continue (job->time);
43514351

@@ -4356,7 +4356,7 @@ static void
43564356
conflict_response_data_free (ConflictResponseData *data)
43574357
{
43584358
g_free (data->new_name);
4359-
g_slice_free (ConflictResponseData, data);
4359+
g_free (data);
43604360
}
43614361

43624362
static GFile *
@@ -6211,7 +6211,7 @@ callback_for_move_to_trash (GHashTable *debuting_uris,
62116211
{
62126212
if (data->real_callback)
62136213
data->real_callback (debuting_uris, !user_cancelled, data->real_data);
6214-
g_slice_free (MoveTrashCBData, data);
6214+
g_free (data);
62156215
}
62166216

62176217
void
@@ -6286,7 +6286,7 @@ nemo_file_operations_copy_move (const GList *item_uris,
62866286
if (g_file_has_uri_scheme (dest, "trash")) {
62876287
MoveTrashCBData *cb_data;
62886288

6289-
cb_data = g_slice_new0 (MoveTrashCBData);
6289+
cb_data = g_new0 (MoveTrashCBData, 1);
62906290
cb_data->real_callback = done_callback;
62916291
cb_data->real_data = done_callback_data;
62926292

libnemo-private/nemo-file-undo-operations.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ typedef struct {
241241
static void
242242
file_undo_info_op_res_free (gpointer data)
243243
{
244-
g_slice_free (FileUndoInfoOpRes, data);
244+
g_free (data);
245245
}
246246

247247
gboolean
@@ -279,7 +279,7 @@ file_undo_info_complete_apply (NemoFileUndoInfo *self,
279279
gboolean success,
280280
gboolean user_cancel)
281281
{
282-
FileUndoInfoOpRes *op_res = g_slice_new0 (FileUndoInfoOpRes);
282+
FileUndoInfoOpRes *op_res = g_new0 (FileUndoInfoOpRes, 1);
283283

284284
op_res->user_cancel = user_cancel;
285285
op_res->success = success;

libnemo-private/nemo-file-utilities.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ ensure_dirs_task_ready_cb (GObject *_source,
13181318
g_list_free (original_dirs);
13191319

13201320
g_hash_table_unref (data->original_dirs_hash);
1321-
g_slice_free (RestoreFilesData, data);
1321+
g_free (data);
13221322
}
13231323

13241324
static void
@@ -1351,7 +1351,7 @@ restore_files_ensure_parent_directories (GHashTable *original_dirs_hash,
13511351
RestoreFilesData *data;
13521352
GTask *ensure_dirs_task;
13531353

1354-
data = g_slice_new0 (RestoreFilesData);
1354+
data = g_new0 (RestoreFilesData, 1);
13551355
data->parent_window = parent_window;
13561356
data->original_dirs_hash = g_hash_table_ref (original_dirs_hash);
13571357

@@ -1417,7 +1417,7 @@ get_types_cb (GObject *source_object,
14171417
data->callback ((const char **) types, data->user_data);
14181418
}
14191419
g_strfreev (types);
1420-
g_slice_free (GetContentTypesData, data);
1420+
g_free (data);
14211421
}
14221422

14231423
void
@@ -1444,7 +1444,7 @@ nemo_get_x_content_types_for_mount_async (GMount *mount,
14441444
return;
14451445
}
14461446

1447-
data = g_slice_new0 (GetContentTypesData);
1447+
data = g_new0 (GetContentTypesData, 1);
14481448
data->callback = callback;
14491449
data->user_data = user_data;
14501450

libnemo-private/nemo-icon-container.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2781,7 +2781,7 @@ finalize (GObject *object)
27812781
g_source_remove (details->a11y_item_action_idle_handler);
27822782
}
27832783

2784-
g_slice_free (NemoViewLayoutConstants, details->view_constants);
2784+
g_free (details->view_constants);
27852785

27862786
g_list_free (details->current_selection);
27872787
g_free(details);
@@ -4920,7 +4920,7 @@ nemo_icon_container_init (NemoIconContainer *container)
49204920

49214921
details->fixed_text_height = -1;
49224922

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

49254925
container->details = details;
49264926

libnemo-private/nemo-icon-info.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ nemo_icon_info_free (NemoIconInfo *icon)
6161
}
6262

6363
g_free (icon->icon_name);
64-
65-
g_slice_free (NemoIconInfo, icon);
64+
g_free (icon);
6665
}
6766

6867
NemoIconInfo *
@@ -106,7 +105,7 @@ nemo_icon_info_create (void)
106105
{
107106
NemoIconInfo *icon;
108107

109-
icon = g_slice_new0 (NemoIconInfo);
108+
icon = g_new0 (NemoIconInfo, 1);
110109

111110
icon->last_use_time = g_get_monotonic_time ();
112111
icon->sole_owner = TRUE;
@@ -270,7 +269,7 @@ icon_key_new (GIcon *icon, int size)
270269
{
271270
IconKey *key;
272271

273-
key = g_slice_new (IconKey);
272+
key = g_new0 (IconKey, 1);
274273
key->icon = g_object_ref (icon);
275274
key->size = size;
276275

@@ -281,7 +280,7 @@ static void
281280
icon_key_free (IconKey *key)
282281
{
283282
g_object_unref (key->icon);
284-
g_slice_free (IconKey, key);
283+
g_free (key);
285284
}
286285

287286
NemoIconInfo *

libnemo-private/nemo-job-queue.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ job_finished_cb (NemoJobQueue *self,
163163
self->priv->running_jobs = g_list_remove (self->priv->running_jobs, job);
164164
self->priv->queued_jobs = g_list_remove (self->priv->queued_jobs, job);
165165

166-
g_slice_free (Job, job);
166+
g_free (job);
167167

168168
nemo_job_queue_start_next_job (self);
169169
}
@@ -189,7 +189,7 @@ nemo_job_queue_add_new_job (NemoJobQueue *self,
189189
return;
190190
}
191191

192-
Job *new_job = g_slice_new0 (Job);
192+
Job *new_job = g_new0 (Job, 1);
193193
new_job->job_func = job_func;
194194
new_job->user_data = user_data;
195195
new_job->cancellable = cancellable;

libnemo-private/nemo-search-engine-advanced.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static void
9292
search_helper_free (SearchHelper *helper)
9393
{
9494
g_free (helper->exec_format);
95-
g_slice_free (SearchHelper, helper);
95+
g_free (helper);
9696
}
9797

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

223-
helper = g_slice_new0 (SearchHelper);
223+
helper = g_new0 (SearchHelper, 1);
224224
helper->exec_format = g_strdup (exec_format);
225225
helper->priority = priority;
226226

libnemo-private/nemo-search-engine.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static GHashTable *fsr_accounting_table = NULL;
180180
FileSearchResult *
181181
file_search_result_new (gchar *uri, gchar *snippet)
182182
{
183-
FileSearchResult *ret = g_slice_new0 (FileSearchResult);
183+
FileSearchResult *ret = g_new0 (FileSearchResult, 1);
184184

185185
ret->uri = uri;
186186
ret->snippet = snippet;
@@ -215,7 +215,7 @@ file_search_result_free (FileSearchResult *res)
215215

216216
g_free (res->uri);
217217
g_free (res->snippet);
218-
g_slice_free (FileSearchResult, res);
218+
g_free (res);
219219
}
220220

221221
void

0 commit comments

Comments
 (0)