[gnome-shell] Stop using GSlice
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Stop using GSlice
- Date: Mon, 19 Oct 2020 18:38:28 +0000 (UTC)
commit 22f691939ce3f6c2d3828afc13b509bdea72d233
Author: Robert Mader <robert mader posteo de>
Date: Mon Oct 19 20:12:27 2020 +0200
Stop using GSlice
It has been inofficially deprecated for years, is known to cause issues
with valgrind and potentially hides memory corruption.
Lets stop using it.
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1473
src/calendar-server/calendar-sources.c | 8 ++++----
src/gtkactionmuxer.c | 8 ++++----
src/hotplug-sniffer/hotplug-sniffer.c | 4 ++--
src/shell-app-cache.c | 4 ++--
src/shell-app.c | 4 ++--
src/shell-global.c | 4 ++--
src/shell-network-agent.c | 10 +++++-----
src/shell-perf-log.c | 6 +++---
src/shell-tray-manager.c | 4 ++--
src/st/st-icon-colors.c | 4 ++--
src/st/st-shadow.c | 10 +++++-----
src/st/st-texture-cache.c | 12 ++++++------
12 files changed, 39 insertions(+), 39 deletions(-)
---
diff --git a/src/calendar-server/calendar-sources.c b/src/calendar-server/calendar-sources.c
index d09956831e..7cca573a81 100644
--- a/src/calendar-server/calendar-sources.c
+++ b/src/calendar-server/calendar-sources.c
@@ -148,7 +148,7 @@ client_data_free (ClientData *data)
{
g_signal_handler_disconnect (data->client, data->backend_died_id);
g_object_unref (data->client);
- g_slice_free (ClientData, data);
+ g_free (data);
}
static void
@@ -378,7 +378,7 @@ calendar_sources_connect_client_sync (CalendarSources *sources,
}
else
{
- client_data = g_slice_new0 (ClientData);
+ client_data = g_new0 (ClientData, 1);
client_data->client = E_CAL_CLIENT (g_object_ref (client));
client_data->backend_died_id = g_signal_connect (client,
"backend-died",
@@ -406,7 +406,7 @@ async_context_free (gpointer ptr)
if (ctx)
{
g_clear_object (&ctx->source);
- g_slice_free (AsyncContext, ctx);
+ g_free (ctx);
}
}
@@ -446,7 +446,7 @@ calendar_sources_connect_client (CalendarSources *sources,
AsyncContext *ctx;
g_autoptr (GTask) task = NULL;
- ctx = g_slice_new0 (AsyncContext);
+ ctx = g_new0 (AsyncContext, 1);
ctx->source = g_object_ref (source);
ctx->source_type = source_type;
ctx->wait_for_connected_seconds = wait_for_connected_seconds;
diff --git a/src/gtkactionmuxer.c b/src/gtkactionmuxer.c
index bbd26d27b0..7e3e86e03e 100644
--- a/src/gtkactionmuxer.c
+++ b/src/gtkactionmuxer.c
@@ -507,7 +507,7 @@ gtk_action_muxer_register_observer (GtkActionObservable *observable,
if (action == NULL)
{
- action = g_slice_new (Action);
+ action = g_new (Action, 1);
action->muxer = muxer;
action->fullname = g_strdup (name);
action->watchers = NULL;
@@ -545,7 +545,7 @@ gtk_action_muxer_free_group (gpointer data)
g_object_unref (group->group);
g_free (group->prefix);
- g_slice_free (Group, group);
+ g_free (group);
}
static void
@@ -560,7 +560,7 @@ gtk_action_muxer_free_action (gpointer data)
g_slist_free (action->watchers);
g_free (action->fullname);
- g_slice_free (Action, action);
+ g_free (action);
}
static void
@@ -711,7 +711,7 @@ gtk_action_muxer_insert (GtkActionMuxer *muxer,
/* TODO: diff instead of ripout and replace */
gtk_action_muxer_remove (muxer, prefix);
- group = g_slice_new (Group);
+ group = g_new (Group, 1);
group->muxer = muxer;
group->group = g_object_ref (action_group);
group->prefix = g_strdup (prefix);
diff --git a/src/hotplug-sniffer/hotplug-sniffer.c b/src/hotplug-sniffer/hotplug-sniffer.c
index fd087fd738..7fd812ea0e 100644
--- a/src/hotplug-sniffer/hotplug-sniffer.c
+++ b/src/hotplug-sniffer/hotplug-sniffer.c
@@ -86,7 +86,7 @@ invocation_data_new (GVariant *params,
{
InvocationData *ret;
- ret = g_slice_new0 (InvocationData);
+ ret = g_new0 (InvocationData, 1);
ret->parameters = g_variant_ref (params);
ret->invocation = g_object_ref (invocation);
@@ -99,7 +99,7 @@ invocation_data_free (InvocationData *data)
g_variant_unref (data->parameters);
g_clear_object (&data->invocation);
- g_slice_free (InvocationData, data);
+ g_free (data);
}
static void
diff --git a/src/shell-app-cache.c b/src/shell-app-cache.c
index 15d4734d0f..44fc8b0d72 100644
--- a/src/shell-app-cache.c
+++ b/src/shell-app-cache.c
@@ -58,7 +58,7 @@ cache_state_free (CacheState *state)
{
g_clear_pointer (&state->folders, g_hash_table_unref);
g_list_free_full (state->app_infos, g_object_unref);
- g_slice_free (CacheState, state);
+ g_free (state);
}
static CacheState *
@@ -66,7 +66,7 @@ cache_state_new (void)
{
CacheState *state;
- state = g_slice_new0 (CacheState);
+ state = g_new0 (CacheState, 1);
state->folders = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
return g_steal_pointer (&state);
diff --git a/src/shell-app.c b/src/shell-app.c
index 6cf4cbaf6a..4fd69e6f13 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -1453,7 +1453,7 @@ create_running_state (ShellApp *app)
g_assert (app->running_state == NULL);
- app->running_state = g_slice_new0 (ShellAppRunningState);
+ app->running_state = g_new0 (ShellAppRunningState, 1);
app->running_state->refcount = 1;
app->running_state->workspace_switch_id =
g_signal_connect (workspace_manager, "workspace-switched",
@@ -1527,7 +1527,7 @@ unref_running_state (ShellAppRunningState *state)
g_clear_object (&state->session);
g_clear_pointer (&state->unique_bus_name, g_free);
- g_slice_free (ShellAppRunningState, state);
+ g_free (state);
}
/**
diff --git a/src/shell-global.c b/src/shell-global.c
index 8ddaa4e46f..d115a6c333 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -1581,7 +1581,7 @@ run_leisure_functions (gpointer data)
if (closure->notify)
closure->notify (closure->user_data);
- g_slice_free (LeisureClosure, closure);
+ g_free (closure);
}
g_slist_free (closures);
@@ -1670,7 +1670,7 @@ shell_global_run_at_leisure (ShellGlobal *global,
gpointer user_data,
GDestroyNotify notify)
{
- LeisureClosure *closure = g_slice_new (LeisureClosure);
+ LeisureClosure *closure = g_new (LeisureClosure, 1);
closure->func = func;
closure->user_data = user_data;
closure->notify = notify;
diff --git a/src/shell-network-agent.c b/src/shell-network-agent.c
index 4fab298e5a..9524fe5201 100644
--- a/src/shell-network-agent.c
+++ b/src/shell-network-agent.c
@@ -81,7 +81,7 @@ shell_agent_request_free (gpointer data)
g_strfreev (request->hints);
g_clear_pointer (&request->entries, g_variant_dict_unref);
- g_slice_free (ShellAgentRequest, request);
+ g_free (request);
}
static void
@@ -360,7 +360,7 @@ shell_network_agent_get_secrets (NMSecretAgentOld *agent,
shell_agent_request_cancel (request);
}
- request = g_slice_new0 (ShellAgentRequest);
+ request = g_new0 (ShellAgentRequest, 1);
request->self = g_object_ref (self);
request->cancellable = g_cancellable_new ();
request->connection = g_object_ref (connection);
@@ -617,7 +617,7 @@ keyring_request_free (KeyringRequest *r)
g_object_unref (r->self);
g_object_unref (r->connection);
- g_slice_free (KeyringRequest, r);
+ g_free (r);
}
static void
@@ -765,7 +765,7 @@ shell_network_agent_save_secrets (NMSecretAgentOld *agent,
{
KeyringRequest *r;
- r = g_slice_new (KeyringRequest);
+ r = g_new (KeyringRequest, 1);
r->n_secrets = 0;
r->self = g_object_ref (agent);
r->connection = g_object_ref (connection);
@@ -812,7 +812,7 @@ shell_network_agent_delete_secrets (NMSecretAgentOld *agent,
NMSettingConnection *s_con;
const gchar *uuid;
- r = g_slice_new (KeyringRequest);
+ r = g_new (KeyringRequest, 1);
r->n_secrets = 0; /* ignored by delete secrets calls */
r->self = g_object_ref (agent);
r->connection = g_object_ref (connection);
diff --git a/src/shell-perf-log.c b/src/shell-perf-log.c
index e108a268a6..95b116905f 100644
--- a/src/shell-perf-log.c
+++ b/src/shell-perf-log.c
@@ -259,7 +259,7 @@ define_event (ShellPerfLog *perf_log,
return NULL;
}
- event = g_slice_new (ShellPerfEvent);
+ event = g_new (ShellPerfEvent, 1);
event->id = perf_log->events->len;
event->name = g_strdup (name);
@@ -501,7 +501,7 @@ shell_perf_log_define_statistic (ShellPerfLog *perf_log,
if (event == NULL)
return;
- statistic = g_slice_new (ShellPerfStatistic);
+ statistic = g_new (ShellPerfStatistic, 1);
statistic->event = event;
statistic->initialized = FALSE;
@@ -598,7 +598,7 @@ shell_perf_log_add_statistics_callback (ShellPerfLog *perf_log,
gpointer user_data,
GDestroyNotify notify)
{
- ShellPerfStatisticsClosure *closure = g_slice_new (ShellPerfStatisticsClosure);
+ ShellPerfStatisticsClosure *closure = g_new (ShellPerfStatisticsClosure, 1);
closure->callback = callback;
closure->user_data = user_data;
diff --git a/src/shell-tray-manager.c b/src/shell-tray-manager.c
index e23179f4ed..03f36a72be 100644
--- a/src/shell-tray-manager.c
+++ b/src/shell-tray-manager.c
@@ -76,7 +76,7 @@ free_tray_icon (gpointer data)
0, 0, NULL, NULL, child);
g_object_unref (child->actor);
}
- g_slice_free (ShellTrayManagerChild, child);
+ g_free (child);
}
static void
@@ -337,7 +337,7 @@ na_tray_icon_added (NaTrayManager *na_manager, GtkWidget *socket,
* the window we put it in match that as well */
gtk_widget_set_visual (win, gtk_widget_get_visual (socket));
- child = g_slice_new0 (ShellTrayManagerChild);
+ child = g_new0 (ShellTrayManagerChild, 1);
child->manager = manager;
child->window = win;
child->socket = socket;
diff --git a/src/st/st-icon-colors.c b/src/st/st-icon-colors.c
index f20a25c7ea..c6a082add3 100644
--- a/src/st/st-icon-colors.c
+++ b/src/st/st-icon-colors.c
@@ -33,7 +33,7 @@ st_icon_colors_new (void)
{
StIconColors *colors;
- colors = g_slice_new0 (StIconColors);
+ colors = g_new0 (StIconColors, 1);
colors->ref_count = 1;
return colors;
@@ -72,7 +72,7 @@ st_icon_colors_unref (StIconColors *colors)
g_return_if_fail (colors->ref_count > 0);
if (g_atomic_int_dec_and_test ((volatile int *)&colors->ref_count))
- g_slice_free (StIconColors, colors);
+ g_free (colors);
}
/**
diff --git a/src/st/st-shadow.c b/src/st/st-shadow.c
index 070e7bf60a..ab3eaa856b 100644
--- a/src/st/st-shadow.c
+++ b/src/st/st-shadow.c
@@ -59,7 +59,7 @@ st_shadow_new (ClutterColor *color,
{
StShadow *shadow;
- shadow = g_slice_new (StShadow);
+ shadow = g_new (StShadow, 1);
shadow->color = *color;
shadow->xoffset = xoffset;
@@ -105,7 +105,7 @@ st_shadow_unref (StShadow *shadow)
g_return_if_fail (shadow->ref_count > 0);
if (g_atomic_int_dec_and_test (&shadow->ref_count))
- g_slice_free (StShadow, shadow);
+ g_free (shadow);
}
/**
@@ -210,7 +210,7 @@ st_shadow_helper_new (StShadow *shadow)
{
StShadowHelper *helper;
- helper = g_slice_new0 (StShadowHelper);
+ helper = g_new0 (StShadowHelper, 1);
helper->shadow = st_shadow_ref (shadow);
return helper;
@@ -255,7 +255,7 @@ st_shadow_helper_copy (StShadowHelper *helper)
{
StShadowHelper *copy;
- copy = g_slice_new (StShadowHelper);
+ copy = g_new (StShadowHelper, 1);
*copy = *helper;
if (copy->pipeline)
cogl_object_ref (copy->pipeline);
@@ -277,7 +277,7 @@ st_shadow_helper_free (StShadowHelper *helper)
cogl_object_unref (helper->pipeline);
st_shadow_unref (helper->shadow);
- g_slice_free (StShadowHelper, helper);
+ g_free (helper);
}
/**
diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c
index a9bf388895..ac4db8f86c 100644
--- a/src/st/st-texture-cache.c
+++ b/src/st/st-texture-cache.c
@@ -353,7 +353,7 @@ texture_load_data_free (gpointer p)
if (data->actors)
g_slist_free_full (data->actors, (GDestroyNotify) g_object_unref);
- g_slice_free (AsyncTextureLoadData, data);
+ g_free (data);
}
/**
@@ -807,7 +807,7 @@ st_texture_cache_free_bind (gpointer data)
StTextureCachePropertyBind *bind = data;
if (bind->weakref_active)
g_object_weak_unref (G_OBJECT (bind->image), st_texture_cache_bind_weak_notify, bind);
- g_slice_free (StTextureCachePropertyBind, bind);
+ g_free (bind);
}
/**
@@ -833,7 +833,7 @@ st_texture_cache_bind_cairo_surface_property (StTextureCache *cache,
gchar *notify_key;
StTextureCachePropertyBind *bind;
- bind = g_slice_new0 (StTextureCachePropertyBind);
+ bind = g_new0 (StTextureCachePropertyBind, 1);
bind->cache = cache;
bind->source = object;
@@ -930,7 +930,7 @@ ensure_request (StTextureCache *cache,
if (pending == NULL)
{
/* Not cached and no pending request, create it */
- *request = g_slice_new0 (AsyncTextureLoadData);
+ *request = g_new0 (AsyncTextureLoadData, 1);
if (policy != ST_TEXTURE_CACHE_POLICY_NONE)
g_hash_table_insert (cache->priv->outstanding_requests, g_strdup (key), *request);
}
@@ -1192,7 +1192,7 @@ on_data_destroy (gpointer data)
g_object_unref (d->gfile);
g_object_unref (d->actor);
g_object_unref (d->cancellable);
- g_slice_free (AsyncImageData, d);
+ g_free (d);
}
static void
@@ -1357,7 +1357,7 @@ st_texture_cache_load_sliced_image (StTextureCache *cache,
g_assert (paint_scale > 0);
g_assert (resource_scale > 0);
- data = g_slice_new0 (AsyncImageData);
+ data = g_new0 (AsyncImageData, 1);
data->grid_width = grid_width;
data->grid_height = grid_height;
data->paint_scale = paint_scale;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]