mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
array.c: fix false assertion in ary_make_shared
* array.c (ary_shrink_capa): shrink the capacity so it fits just with the length. * array.c (ary_make_shared): release never used elements from frozen array to be shared. [ruby-dev:47416] [Bug #8510] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4cdd6f6ab8
commit
c5c201f624
2 changed files with 19 additions and 1 deletions
|
@ -1,3 +1,11 @@
|
|||
Tue Jun 11 16:15:03 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* array.c (ary_shrink_capa): shrink the capacity so it fits just with
|
||||
the length.
|
||||
|
||||
* array.c (ary_make_shared): release never used elements from frozen
|
||||
array to be shared. [ruby-dev:47416] [Bug #8510]
|
||||
|
||||
Tue Jun 11 12:49:01 2013 Zachary Scott <zachary@zacharyscott.net>
|
||||
|
||||
* doc/re.rdoc: Rename to doc/regexp.rdoc
|
||||
|
|
12
array.c
12
array.c
|
@ -179,6 +179,16 @@ ary_resize_capa(VALUE ary, long capacity)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ary_shrink_capa(VALUE ary)
|
||||
{
|
||||
long capacity = ARY_HEAP_LEN(ary);
|
||||
long old_capa = RARRAY(ary)->as.heap.aux.capa;
|
||||
assert(old_capa >= capacity);
|
||||
if (old_capa > capacity)
|
||||
REALLOC_N(RARRAY(ary)->as.heap.ptr, VALUE, capacity);
|
||||
}
|
||||
|
||||
static void
|
||||
ary_double_capa(VALUE ary, long min)
|
||||
{
|
||||
|
@ -510,7 +520,7 @@ ary_make_shared(VALUE ary)
|
|||
return ary;
|
||||
}
|
||||
else if (OBJ_FROZEN(ary)) {
|
||||
ary_resize_capa(ary, ARY_HEAP_LEN(ary));
|
||||
ary_shrink_capa(ary);
|
||||
FL_SET_SHARED_ROOT(ary);
|
||||
ARY_SET_SHARED_NUM(ary, 1);
|
||||
return ary;
|
||||
|
|
Loading…
Add table
Reference in a new issue