1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* array.c (rb_ary_decrement_share): fix to work recycling

shared-array without the following.  [ruby-dev:36991]

* array.c (ary_make_substitution): don't recycle substitution array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
wanabe 2008-10-31 03:49:29 +00:00
parent 30887efb8a
commit 5eacf68c2a
2 changed files with 18 additions and 5 deletions

View file

@ -1,3 +1,10 @@
Fri Oct 31 12:42:45 2008 wanabe <s.wanabe@gmail.com>
* array.c (rb_ary_decrement_share): fix to work recycling
shared-array without the following. [ruby-dev:36991]
* array.c (ary_make_substitution): don't recycle substitution array.
Fri Oct 31 12:27:52 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
* spec/default.mspec: supports that the build directory != srcdir.

16
array.c
View file

@ -177,7 +177,7 @@ rb_ary_decrement_share(VALUE shared)
{
if (shared) {
int num = ARY_SHARED_NUM(shared) - 1;
if (num == 0 && RBASIC(shared)->klass) {
if (num == 0) {
rb_ary_free(shared);
rb_gc_force_recycle(shared);
}
@ -202,13 +202,19 @@ rb_ary_unshare_safe(VALUE ary) {
}
}
static void
rb_ary_set_shared(VALUE ary, VALUE shared)
{
static VALUE
rb_ary_increment_share(VALUE shared) {
int num = ARY_SHARED_NUM(shared);
if (num >= 0) {
ARY_SET_SHARED_NUM(shared, num + 1);
}
return shared;
}
static void
rb_ary_set_shared(VALUE ary, VALUE shared)
{
rb_ary_increment_share(shared);
FL_SET_SHARED(ary);
ARY_SET_SHARED(ary, shared);
}
@ -396,7 +402,7 @@ ary_make_substitution(VALUE ary)
return subst;
}
else {
return ary_make_shared(ary);
return rb_ary_increment_share(ary_make_shared(ary));
}
}