summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlli Salli <olli.salli@collabora.co.uk>2007-06-01 12:43:40 +0000
committerOlli Salli <olli.salli@collabora.co.uk>2007-06-01 12:43:40 +0000
commit77c4804af7a6310287da8f6e113940e8661b0899 (patch)
tree14bd0a3cfbeb260e8fe05e9d45ce9b54a1ab9e7f
parentee02fdd45a291af37b9ecc0e372f8680fc53572c (diff)
Provide implementations of g_hash_table_{ref,unref} for GLib < 2.10, they are required for TpPresenceMixin
-rw-r--r--telepathy-glib/presence-mixin.c70
-rw-r--r--telepathy-glib/presence-mixin.h8
2 files changed, 78 insertions, 0 deletions
diff --git a/telepathy-glib/presence-mixin.c b/telepathy-glib/presence-mixin.c
index 3e8fa698d..94a14ee93 100644
--- a/telepathy-glib/presence-mixin.c
+++ b/telepathy-glib/presence-mixin.c
@@ -62,6 +62,76 @@
#include "internal-debug.h"
+
+#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 10))
+
+
+static GQuark
+gash_table_refcount_quark ()
+{
+ static GQuark quark = 0;
+
+ if (!quark)
+ quark = g_quark_from_static_string ("tp_presence_mixin_gash_table_refcount");
+
+ return quark;
+}
+
+
+void
+tp_gash_table_ref (GHashTable *hash_table)
+{
+ guint refcount;
+
+ DEBUG ("called.");
+
+ refcount = GPOINTER_TO_UINT (g_dataset_id_get_data ((hash_table),
+ gash_table_refcount_quark ()));
+
+ if (!refcount)
+ refcount = 1;
+
+ refcount++;
+ g_dataset_id_set_data (hash_table, gash_table_refcount_quark (),
+ GUINT_TO_POINTER (refcount));
+
+ DEBUG ("Refcount for %p now %u", hash_table, refcount);
+}
+
+
+void
+tp_gash_table_unref (GHashTable *hash_table)
+{
+ guint refcount;
+
+ DEBUG ("called.");
+
+ refcount = GPOINTER_TO_UINT (g_dataset_id_get_data ((hash_table),
+ gash_table_refcount_quark ()));
+
+ g_assert (refcount != G_MAXUINT);
+
+ if (!refcount)
+ refcount = 1;
+
+ if (!--refcount)
+ {
+ g_hash_table_destroy (hash_table);
+ g_dataset_destroy (hash_table);
+ }
+ else
+ {
+ g_dataset_id_set_data (hash_table, gash_table_refcount_quark (),
+ GUINT_TO_POINTER (refcount));
+ }
+
+ DEBUG ("Refcount for %p now %u", hash_table, refcount);
+}
+
+
+#endif
+
+
struct _TpPresenceMixinPrivate
{
/* ... */
diff --git a/telepathy-glib/presence-mixin.h b/telepathy-glib/presence-mixin.h
index 5c538aaef..d94ce945e 100644
--- a/telepathy-glib/presence-mixin.h
+++ b/telepathy-glib/presence-mixin.h
@@ -28,6 +28,14 @@
G_BEGIN_DECLS
+#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 10))
+#define g_hash_table_ref tp_gash_table_ref
+#define g_hash_table_unref tp_gash_table_unref
+
+void tp_gash_table_ref(GHashTable *hash_table);
+void tp_gash_table_unref(GHashTable *hash_table);
+#endif
+
typedef struct _TpPresenceStatusOptionalArgumentSpec
TpPresenceStatusOptionalArgumentSpec;
typedef struct _TpPresenceStatusSpec TpPresenceStatusSpec;