From 524acd75966d283dda0ba7d748b16ce6902a2868 Mon Sep 17 00:00:00 2001 From: Ben Chan Date: Fri, 30 Jun 2017 06:27:07 -0700 Subject: [PATCH] iface-modem: use g_new0 instead of g_slice_new0 to allocate context By using g_new0 instead of g_slice_new0 to allocate certain context structs, we can simply use g_free as GDestroyNotify in g_task_set_task_data and get rid of those functions that solely wrap the g_slice_free call. --- src/mm-iface-modem.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index a8e60470..cd462a38 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -94,12 +94,6 @@ typedef struct { guint state_changed_wait_id; } WaitForFinalStateContext; -static void -wait_for_final_state_context_free (WaitForFinalStateContext *ctx) -{ - g_slice_free (WaitForFinalStateContext, ctx); -} - static void wait_for_final_state_context_complete (GTask *task, MMModemState state, @@ -220,10 +214,10 @@ mm_iface_modem_wait_for_final_state (MMIfaceModem *self, /* Otherwise, we'll need to wait for the exact one we want */ } - ctx = g_slice_new0 (WaitForFinalStateContext); + ctx = g_new0 (WaitForFinalStateContext, 1); ctx->final_state = final_state; - g_task_set_task_data (task, ctx, (GDestroyNotify)wait_for_final_state_context_free); + g_task_set_task_data (task, ctx, g_free); /* Want to get notified when modem state changes */ ctx->state_changed_id = g_signal_connect (self, @@ -246,12 +240,6 @@ typedef struct { guint pin_check_timeout_id; } InternalLoadUnlockRequiredContext; -static void -internal_load_unlock_required_context_free (InternalLoadUnlockRequiredContext *ctx) -{ - g_slice_free (InternalLoadUnlockRequiredContext, ctx); -} - static MMModemLock internal_load_unlock_required_finish (MMIfaceModem *self, GAsyncResult *res, @@ -365,10 +353,10 @@ internal_load_unlock_required (MMIfaceModem *self, InternalLoadUnlockRequiredContext *ctx; GTask *task; - ctx = g_slice_new0 (InternalLoadUnlockRequiredContext); + ctx = g_new0 (InternalLoadUnlockRequiredContext, 1); task = g_task_new (self, NULL, callback, user_data); - g_task_set_task_data (task, ctx, (GDestroyNotify)internal_load_unlock_required_context_free); + g_task_set_task_data (task, ctx, g_free); if (!MM_IFACE_MODEM_GET_INTERFACE (self)->load_unlock_required || !MM_IFACE_MODEM_GET_INTERFACE (self)->load_unlock_required_finish) {