From 05a34a764d376a9e4a400bd6989bb6a2e6ea6d17 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 13 Jul 2006 15:12:56 +0000 Subject: [PATCH] * array.c (rb_ary_pop): may cause realloc oscillation. a patch from MORITA Naoyuki . [ruby-dev:29028] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ array.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 832e599368..c108a69d98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Jul 14 00:10:15 2006 Yukihiro Matsumoto + + * array.c (rb_ary_pop): may cause realloc oscillation. a patch + from MORITA Naoyuki . + [ruby-dev:29028] + Thu Jul 13 22:23:56 2006 Hidetoshi NAGAI * ext/tk/lib/tk/composite.rb: improve handling of the classname on the diff --git a/array.c b/array.c index 708a4900c0..5bf0e9979d 100644 --- a/array.c +++ b/array.c @@ -454,7 +454,7 @@ rb_ary_pop(VALUE ary) rb_ary_modify_check(ary); if (RARRAY(ary)->len == 0) return Qnil; if (!FL_TEST(ary, ELTS_SHARED) && - RARRAY(ary)->len * 2 < RARRAY(ary)->aux.capa && + RARRAY(ary)->len * 3 < RARRAY(ary)->aux.capa && RARRAY(ary)->aux.capa > ARY_DEFAULT_SIZE) { RARRAY(ary)->aux.capa = RARRAY(ary)->len * 2; REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->aux.capa);