summaryrefslogtreecommitdiff
path: root/src/glibcompat.h
diff options
context:
space:
mode:
authorJasmine Hassan <[email protected]>2012-10-29 04:21:19 +0200
committerJasmine Hassan <[email protected]>2012-12-22 05:21:53 +0200
commitab206cf53ff4380c63f031101c36b6bc0c7a8489 (patch)
tree7fcbd3920c3b55f3054238b395fef4f116bd6542 /src/glibcompat.h
parentf5f249b7e2bb2206222ce5d0ae4ed95d8e99b8c2 (diff)
downloadcaja-ab206cf53ff4380c63f031101c36b6bc0c7a8489.tar.bz2
caja-ab206cf53ff4380c63f031101c36b6bc0c7a8489.tar.xz
[places-sidebar] plug leak in _dispose, add g_clear_object in glibcomat.h
to cleanup code a bit. http://git.gnome.org/browse/nautilus/commit/?id=c6fa6b2062a1adf3e4945824048b3771edb35ebe for g_clear_object compatibility: https://gitorious.org/vaapi/gstreamer-vaapi/commit/ab2ec5e2541834c2490a78ec839850df2b075cf5?format=diff
Diffstat (limited to 'src/glibcompat.h')
-rw-r--r--src/glibcompat.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/glibcompat.h b/src/glibcompat.h
index a83da239..4c71b2b5 100644
--- a/src/glibcompat.h
+++ b/src/glibcompat.h
@@ -38,4 +38,22 @@ g_list_free_full (GList *list, GDestroyNotify free_func)
}
#endif
+#if !GLIB_CHECK_VERSION(2,28,0)
+static inline void
+g_clear_object_inline(volatile GObject **object_ptr)
+{
+ gpointer * const ptr = (gpointer)object_ptr;
+ gpointer old;
+
+ do {
+ old = g_atomic_pointer_get(ptr);
+ } while G_UNLIKELY(!g_atomic_pointer_compare_and_exchange(ptr, old, NULL));
+
+ if (old)
+ g_object_unref(old);
+}
+#undef g_clear_object
+#define g_clear_object(obj) g_clear_object_inline((volatile GObject **)(obj))
+#endif
+
#endif /* GLIB_COMPAT_H */