diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-05-07 13:26:03 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-03 16:08:51 +0200 |
commit | c721acaf9702425beb16c20d86c11e2e42f5d244 (patch) | |
tree | fa8aa188fbc25ead3a1c1af71a919b1c552a864a /src/qmi-device.c | |
parent | ef1547431a1469b7f6091b1c2323838c7638760a (diff) | |
download | external_libqmi-c721acaf9702425beb16c20d86c11e2e42f5d244.zip external_libqmi-c721acaf9702425beb16c20d86c11e2e42f5d244.tar.gz external_libqmi-c721acaf9702425beb16c20d86c11e2e42f5d244.tar.bz2 |
device: plug memleak, ensure timeout context gets freed
Diffstat (limited to 'src/qmi-device.c')
-rw-r--r-- | src/qmi-device.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/qmi-device.c b/src/qmi-device.c index 4715b74..6cbe41b 100644 --- a/src/qmi-device.c +++ b/src/qmi-device.c @@ -187,6 +187,12 @@ typedef struct { gpointer key; } TransactionTimeoutContext; +static void +transaction_timeout_context_free (TransactionTimeoutContext *ctx) +{ + g_slice_free (TransactionTimeoutContext, ctx); +} + static gboolean transaction_timed_out (TransactionTimeoutContext *ctx) { @@ -224,10 +230,12 @@ device_store_transaction (QmiDevice *self, /* Once it gets into the HT, setup the timeout */ timeout_ctx = g_slice_new (TransactionTimeoutContext); timeout_ctx->self = self; - timeout_ctx->key = key; - tr->timeout_id = g_timeout_add_seconds (timeout, - (GSourceFunc)transaction_timed_out, - timeout_ctx); + timeout_ctx->key = key; /* valid as long as the transaction is in the HT */ + tr->timeout_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, + timeout, + (GSourceFunc)transaction_timed_out, + timeout_ctx, + (GDestroyNotify)transaction_timeout_context_free); } static Transaction * |