From 846cafcbf450e6e31171973b0758adc9c520942a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 24 Jul 2017 12:30:57 +0100 Subject: [PATCH] Add a simplified backport of g_steal_pointer() This will be used in tests later in the branch. Signed-off-by: Simon McVittie https://bugs.freedesktop.org/show_bug.cgi?id=101354 --- configure.ac | 2 +- test/test-utils-glib.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 53c8b348..8b39348a 100644 --- a/configure.ac +++ b/configure.ac @@ -263,7 +263,7 @@ fi # or binaries. AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_40], [Ignore post-2.40 deprecations]) -AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_40], [Prevent post-2.40 APIs]) +AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_44], [Prevent post-2.44 APIs]) with_glib=yes diff --git a/test/test-utils-glib.h b/test/test-utils-glib.h index 2e1073f0..52d66b91 100644 --- a/test/test-utils-glib.h +++ b/test/test-utils-glib.h @@ -89,4 +89,19 @@ void test_rmdir_must_exist (const gchar *path); void test_rmdir_if_exists (const gchar *path); void test_mkdir (const gchar *path, gint mode); +#if !GLIB_CHECK_VERSION(2, 44, 0) +#define g_steal_pointer(x) backported_g_steal_pointer (x) +/* A simplified version of g_steal_pointer without type-safety. */ +static inline gpointer +backported_g_steal_pointer (gpointer pointer_to_pointer) +{ + gpointer *pp = pointer_to_pointer; + gpointer ret; + + ret = *pp; + *pp = NULL; + return ret; +} +#endif + #endif -- 2.13.3