From d3881bb1bfff0002e9701be039f3c2d0af4ad203 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 11 Jul 2018 21:52:31 +0000 Subject: [PATCH] Revert "Merge branch 'type-safe-g-clear-pointer-1425' into 'master'" This reverts merge request !165 --- glib/gmem.h | 11 ----------- gobject/gobject.c | 2 +- gobject/gobject.h | 2 +- gobject/tests/reference.c | 2 +- 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/glib/gmem.h b/glib/gmem.h index bf262f66e..5cccb045c 100644 --- a/glib/gmem.h +++ b/glib/gmem.h @@ -110,16 +110,6 @@ gpointer g_try_realloc_n (gpointer mem, gsize n_blocks, gsize n_block_bytes) G_GNUC_WARN_UNUSED_RESULT; -#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) && !defined(__cplusplus) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58 -#define g_clear_pointer(pp, destroy) \ - G_STMT_START { \ - G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \ - __typeof__(*(pp)) _ptr = *(pp); \ - *(pp) = NULL; \ - if (_ptr) \ - destroy (_ptr); \ - } G_STMT_END -#else /* __GNUC__ */ #define g_clear_pointer(pp, destroy) \ G_STMT_START { \ G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \ @@ -137,7 +127,6 @@ gpointer g_try_realloc_n (gpointer mem, _destroy (_p); \ } \ } G_STMT_END -#endif /* __GNUC__ */ /** * g_steal_pointer: diff --git a/gobject/gobject.c b/gobject/gobject.c index efb8ecab5..555ca3fae 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -3378,7 +3378,7 @@ g_object_unref (gpointer _object) **/ #undef g_clear_object void -g_clear_object (GObject **object_ptr) +g_clear_object (volatile GObject **object_ptr) { g_clear_pointer (object_ptr, g_object_unref); } diff --git a/gobject/gobject.h b/gobject/gobject.h index 9abe87330..838046fe0 100644 --- a/gobject/gobject.h +++ b/gobject/gobject.h @@ -668,7 +668,7 @@ G_STMT_START { \ G_OBJECT_WARN_INVALID_PSPEC ((object), "property", (property_id), (pspec)) GLIB_AVAILABLE_IN_ALL -void g_clear_object (GObject **object_ptr); +void g_clear_object (volatile GObject **object_ptr); #define g_clear_object(object_ptr) g_clear_pointer ((object_ptr), g_object_unref) /** diff --git a/gobject/tests/reference.c b/gobject/tests/reference.c index 9508ee741..b05150e96 100644 --- a/gobject/tests/reference.c +++ b/gobject/tests/reference.c @@ -132,7 +132,7 @@ test_clear (void) static void test_clear_function (void) { - GObject *o = NULL; + volatile GObject *o = NULL; GObject *tmp; (g_clear_object) (&o);