summaryrefslogtreecommitdiff
path: root/gc.h
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-14 23:59:23 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-14 23:59:23 (GMT)
commitbb8abf62d3cb783b6b8ffeffb67c5ff519332c20 (patch)
tree056ff384515a4d220ef0e5b7216a4a3d7d9d0101 /gc.h
parent994460c4db639d098ec72ca54b3442f5ea05336f (diff)
gc.h: evaluate the macro argument only once
* gc.h (RUBY_MARK_UNLESS_NULL): evaluate the argument only once to get rid of inadvertent side effects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.h')
-rw-r--r--gc.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/gc.h b/gc.h
index 19c712b..d1021df 100644
--- a/gc.h
+++ b/gc.h
@@ -57,7 +57,10 @@ rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
#define RUBY_GC_INFO if(0)printf
#endif
-#define RUBY_MARK_UNLESS_NULL(ptr) if(RTEST(ptr)){rb_gc_mark(ptr);}
+#define RUBY_MARK_UNLESS_NULL(ptr) do { \
+ VALUE markobj = (ptr); \
+ if (RTEST(markobj)) {rb_gc_mark(markobj);} \
+} while (0)
#define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);(ptr)=NULL;}
#if STACK_GROW_DIRECTION > 0