aboutsummaryrefslogtreecommitdiffstats
path: root/gc.h
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-14 23:59:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-14 23:59:23 +0000
commit1ca0f9452ba2aa5f286578b2a37be05fc2d3ed39 (patch)
tree056ff384515a4d220ef0e5b7216a4a3d7d9d0101 /gc.h
parent4659b47a9ebc9476fdf313e5e56abe3d182bd726 (diff)
downloadruby-1ca0f9452ba2aa5f286578b2a37be05fc2d3ed39.tar.gz
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 19c712b44d..d1021df444 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