[Xfce4-commits] <midori:master> Adjust katze_(foo_)assign to work inside one-line if's

Christian Dywan noreply at xfce.org
Fri Oct 16 20:42:02 CEST 2009


Updating branch refs/heads/master
         to 3fec0a02651cd36c9c1f84cda1312ff3e144485b (commit)
       from 640b37e5ec80922c5da76ae0b799dbbbb7550f68 (commit)

commit 3fec0a02651cd36c9c1f84cda1312ff3e144485b
Author: Christian Dywan <christian at twotoasts.de>
Date:   Fri Oct 16 19:37:49 2009 +0200

    Adjust katze_(foo_)assign to work inside one-line if's

 katze/katze-utils.h |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/katze/katze-utils.h b/katze/katze-utils.h
index 5d237d1..3cd418d 100644
--- a/katze/katze-utils.h
+++ b/katze/katze-utils.h
@@ -34,11 +34,12 @@ G_BEGIN_DECLS
  * Frees @lvalue if needed and assigns it the value of @rvalue.
  **/
 #define katze_assign(lvalue, rvalue) \
-    if (1) \
+    do \
     { \
         g_free (lvalue); \
         lvalue = rvalue; \
-    }
+    } \
+    while (0)
 
 /**
  * katze_object_assign:
@@ -48,12 +49,13 @@ G_BEGIN_DECLS
  * Unrefs @lvalue if needed and assigns it the value of @rvalue.
  **/
 #define katze_object_assign(lvalue, rvalue) \
-    if (1) \
+    do \
     { \
         if (lvalue) \
             g_object_unref (lvalue); \
         lvalue = rvalue; \
-    }
+    } \
+    while (0)
 
 /**
  * katze_strv_assign:
@@ -65,11 +67,12 @@ G_BEGIN_DECLS
  * Since: 0.1.7
  **/
 #define katze_strv_assign(lvalue, rvalue) \
-    if (1) \
+    do \
     { \
         g_strfreev (lvalue); \
         lvalue = rvalue; \
-    }
+    } \
+    while (0)
 
 GtkWidget*
 katze_property_proxy                (gpointer     object,



More information about the Xfce4-commits mailing list