telepathy-glib: Util: Add _tp_g_list_copy_deep()
Xavier Claessens
xclaesse at kemper.freedesktop.org
Wed Sep 5 07:29:34 PDT 2012
Module: telepathy-glib
Branch: master
Commit: 3df9ac884e876dc685951556a28c0f085e3938a3
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=3df9ac884e876dc685951556a28c0f085e3938a3
Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date: Wed Sep 5 10:53:22 2012 +0200
Util: Add _tp_g_list_copy_deep()
This implementation is less optimized than g_list_copy_deep() because it
iterates the list twice. But it will be removed once we depend on
glib 2.34
---
telepathy-glib/util-internal.h | 5 +++++
telepathy-glib/util.c | 19 +++++++++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/telepathy-glib/util-internal.h b/telepathy-glib/util-internal.h
index d035270..9410648 100644
--- a/telepathy-glib/util-internal.h
+++ b/telepathy-glib/util-internal.h
@@ -105,4 +105,9 @@ GPtrArray *_tp_contacts_from_values (GHashTable *table);
GList *_tp_object_list_copy (GList *l);
void _tp_object_list_free (GList *l);
+/* This can be removed once we depend on GLib 2.34 */
+GList *_tp_g_list_copy_deep (GList *list,
+ GCopyFunc func,
+ gpointer user_data);
+
#endif /* __TP_UTIL_INTERNAL_H__ */
diff --git a/telepathy-glib/util.c b/telepathy-glib/util.c
index 0ee31a3..250a890 100644
--- a/telepathy-glib/util.c
+++ b/telepathy-glib/util.c
@@ -2057,3 +2057,22 @@ _tp_object_list_free (GList *l)
{
g_list_free_full (l, g_object_unref);
}
+
+GList *
+_tp_g_list_copy_deep (GList *list,
+ GCopyFunc func,
+ gpointer user_data)
+{
+ GList *ret = NULL;
+ GList *l;
+
+ ret = g_list_copy (list);
+
+ if (func != NULL)
+ {
+ for (l = ret; l != NULL; l = l->next)
+ l->data = func (l->data, user_data);
+ }
+
+ return ret;
+}
More information about the telepathy-commits
mailing list