[telepathy-glib/master] b.fd.o #24654: tp_account_prepare_async: copy @features argument
David Laban
david.laban at collabora.co.uk
Mon Nov 16 18:52:04 PST 2009
Note that the functions _tp_account_features_(copy|sizeof|free)
are probably generally useful. Will probably end up copy-pasting
them into AccountManager too.
---
telepathy-glib/account.c | 36 +++++++++++++++++++++++++++++++++++-
1 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c
index f18d999..24e4e76 100644
--- a/telepathy-glib/account.c
+++ b/telepathy-glib/account.c
@@ -274,6 +274,39 @@ _tp_account_check_features (TpAccount *self,
return TRUE;
}
+static gsize
+_tp_account_features_sizeof (const GQuark *features)
+{
+ guint n_features = 0;
+
+ while (features != NULL && features[n_features] != 0)
+ n_features++;
+
+ return sizeof (GQuark) * (n_features + 1);
+}
+
+static GQuark *
+_tp_account_features_copy (const GQuark *features)
+{
+ gsize size;
+ GQuark *copy;
+ if (features == NULL)
+ return NULL;
+ size = _tp_account_features_sizeof (features);
+ copy = (GQuark *) g_slice_copy (size, features);
+return copy;
+}
+
+static void
+_tp_account_features_free (const GQuark *features)
+{
+ gsize size;
+ if (features == NULL)
+ return;
+ size = _tp_account_features_sizeof (features);
+ g_slice_free1 (size, features);
+}
+
static void
_tp_account_become_ready (TpAccount *self,
GQuark feature)
@@ -318,6 +351,7 @@ _tp_account_become_ready (TpAccount *self,
g_simple_async_result_complete (cb->result);
g_object_unref (cb->result);
+ _tp_account_features_free (cb->features);
g_slice_free (TpAccountFeatureCallback, cb);
}
@@ -2604,7 +2638,7 @@ tp_account_prepare_async (TpAccount *account,
cb = g_slice_new0 (TpAccountFeatureCallback);
cb->result = result;
- cb->features = features;
+ cb->features = _tp_account_features_copy (features);
priv->callbacks = g_list_prepend (priv->callbacks, cb);
}
}
--
1.5.6.5
More information about the telepathy-commits
mailing list