aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Chan <benchan@chromium.org>2017-06-30 06:27:07 -0700
committerAleksander Morgado <aleksander@aleksander.es>2017-06-30 15:33:03 +0200
commit524acd75966d283dda0ba7d748b16ce6902a2868 (patch)
tree58fc226c229ac5d8b1c10a048bd1f143dba85e0b /src
parentd49cf585dd1f3e6f06b4ee23bbd3ca5278f2739c (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/mm-iface-modem.c20
1 files 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
@@ -95,12 +95,6 @@ typedef struct {
} 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,
GError *error)
@@ -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) {