g_clear_pointer: use the same static checks than g_clear_object in glib-2-32

This commit is contained in:
Xavier Claessens 2012-04-30 17:02:06 +02:00
parent 19ac408650
commit cbf06d8fa9

View File

@ -99,11 +99,12 @@ gpointer g_try_realloc_n (gpointer mem,
#define g_clear_pointer(pp, destroy) \
G_STMT_START { \
G_STATIC_ASSERT (sizeof (*(pp)) == sizeof (gpointer)); \
G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \
/* Only one access, please */ \
gpointer *_pp = (gpointer *) pp; \
gpointer *_pp = (gpointer *) (pp); \
gpointer _p; \
\
(void) (0 ? (gpointer) *(pp) : 0); \
do \
_p = g_atomic_pointer_get (_pp); \
while G_UNLIKELY (!g_atomic_pointer_compare_and_exchange (_pp, _p, NULL)); \