From 172825390ad7166987003245b26d8dd66b84fab3 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Tue, 15 Nov 2011 16:13:46 +0000 Subject: [PATCH] Deprecate setptr in favour of SETPTR SETPTR makes it clear that a macro is being used in code. Restore setptr without do/while in case of use without semi-colon. --- src/utils.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/utils.h b/src/utils.h index 66d47781..d257d996 100644 --- a/src/utils.h +++ b/src/utils.h @@ -37,14 +37,18 @@ /** Assigns @a result to @a ptr, then frees the old value. * @a result can be an expression using the 'old' value of @a ptr. - * E.g. @code setptr(str, g_strndup(str, 5)); @endcode + * E.g. @code SETPTR(str, g_strndup(str, 5)); @endcode **/ +#define SETPTR(ptr, result) \ + do setptr(ptr, result) while (0) + +/** @deprecated 2011/11/15 - use SETPTR() instead. */ #define setptr(ptr, result) \ - do {\ + {\ gpointer setptr_tmp = ptr;\ ptr = result;\ g_free(setptr_tmp);\ - } while (0) + } /** Duplicates a string on the stack using @c g_alloca(). * Like glibc's @c strdupa(), but portable.