summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-28 23:18:15 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-28 23:18:15 +0000
commit1c0add85ca100eb93a3455aa51a4ffe13bb72e35 (patch)
treebaf5ea99fc61d9bd1bbe556c29e91514c8965c7a /thread.c
parentf0a2b08d02e9e439e8d700f49e6a348b2d3ee9e0 (diff)
merges r30922 and r30924 from trunk into ruby_1_9_2.
-- * prevent temporary objects from GC, and should not use RSTRING_PTR() for function calls since it evaluates the argument a couple of times. -- * thread.c (exec_recursive): prevent temporary objects from GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@31765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/thread.c b/thread.c
index 669c7bdd65..76f4cb6763 100644
--- a/thread.c
+++ b/thread.c
@@ -3637,10 +3637,14 @@ exec_recursive_i(VALUE tag, struct exec_recursive_params *p)
static VALUE
exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE arg, int outer)
{
+ VALUE result = Qundef;
struct exec_recursive_params p;
int outermost;
p.list = recursive_list_access();
p.objid = rb_obj_id(obj);
+ p.obj = obj;
+ p.pairid = pairid;
+ p.arg = arg;
outermost = outer && !recursive_check(p.list, ID2SYM(recursive_key), 0);
if (recursive_check(p.list, p.objid, pairid)) {
@@ -3650,11 +3654,7 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE
return (*func)(obj, arg, TRUE);
}
else {
- VALUE result = Qundef;
p.func = func;
- p.obj = obj;
- p.pairid = pairid;
- p.arg = arg;
if (outermost) {
recursive_push(p.list, ID2SYM(recursive_key), 0);
@@ -3667,8 +3667,9 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE
else {
result = exec_recursive_i(0, &p);
}
- return result;
}
+ *(volatile struct exec_recursive_params *)&p;
+ return result;
}
/*