[evolution-data-server/openismus-work-3-8: 85/116] Backported e_weak_ref_new()/e_weak_ref_free()
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work-3-8: 85/116] Backported e_weak_ref_new()/e_weak_ref_free()
- Date: Tue, 1 Oct 2013 19:05:23 +0000 (UTC)
commit 088cc6a61806f78d3a47cf7bf446907957d70972
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Mon Aug 19 13:22:13 2013 +0200
Backported e_weak_ref_new()/e_weak_ref_free()
These will be needed by the EBookClientCursor.
libedataserver/e-data-server-util.c | 40 +++++++++++++++++++++++++++++++++++
libedataserver/e-data-server-util.h | 3 ++
2 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/libedataserver/e-data-server-util.c b/libedataserver/e-data-server-util.c
index 864da07..4c45707 100644
--- a/libedataserver/e-data-server-util.c
+++ b/libedataserver/e-data-server-util.c
@@ -1548,6 +1548,46 @@ e_async_closure_callback (GObject *object,
g_main_loop_quit (real_closure->loop);
}
+/**
+ * e_weak_ref_new:
+ * @object: (allow-none): a #GObject or %NULL
+ *
+ * Allocates a new #GWeakRef and calls g_weak_ref_set() with @object.
+ *
+ * Free the returned #GWeakRef with e_weak_ref_free().
+ *
+ * Returns: a new #GWeakRef
+ *
+ * Since: 3.10
+ **/
+GWeakRef *
+e_weak_ref_new (gpointer object)
+{
+ GWeakRef *weak_ref;
+
+ weak_ref = g_slice_new0 (GWeakRef);
+ g_weak_ref_set (weak_ref, object);
+
+ return weak_ref;
+}
+
+/**
+ * e_weak_ref_free:
+ * @weak_ref: a #GWeakRef
+ *
+ * Frees a #GWeakRef created by e_weak_ref_new().
+ *
+ * Since: 3.10
+ **/
+void
+e_weak_ref_free (GWeakRef *weak_ref)
+{
+ g_return_if_fail (weak_ref != NULL);
+
+ g_weak_ref_set (weak_ref, NULL);
+ g_slice_free (GWeakRef, weak_ref);
+}
+
#ifdef G_OS_WIN32
#include <windows.h>
diff --git a/libedataserver/e-data-server-util.h b/libedataserver/e-data-server-util.h
index cf8ce2d..194c00c 100644
--- a/libedataserver/e-data-server-util.h
+++ b/libedataserver/e-data-server-util.h
@@ -117,6 +117,9 @@ void e_async_closure_callback (GObject *object,
GAsyncResult *result,
gpointer closure);
+GWeakRef *e_weak_ref_new (gpointer object);
+void e_weak_ref_free (GWeakRef *weak_ref);
+
#ifdef G_OS_WIN32
const gchar * e_util_get_prefix (void) G_GNUC_CONST;
const gchar * e_util_get_cp_prefix (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]