зеркало из https://github.com/github/ruby.git
* ext/bigdecimal/bigdecimal.c (VpAlloc): ensure buf does not get
collected. based on a patch masaya tarui at [ruby-dev:41213]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
7eb6e562e5
Коммит
66abf4ad68
|
@ -1,3 +1,8 @@
|
|||
Sat May 8 11:07:41 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/bigdecimal/bigdecimal.c (VpAlloc): ensure buf does not get
|
||||
collected. based on a patch masaya tarui at [ruby-dev:41213].
|
||||
|
||||
Sat May 8 10:03:39 2010 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/lib/socket.rb (BasicSocket#connect_address): MacOS X 10.6
|
||||
|
|
|
@ -2593,7 +2593,7 @@ VpAlloc(U_LONG mx, const char *szVal)
|
|||
int sign=1;
|
||||
Real *vp = NULL;
|
||||
U_LONG mf = VpGetPrecLimit();
|
||||
volatile VALUE buf;
|
||||
VALUE buf;
|
||||
|
||||
mx = (mx + BASE_FIG - 1) / BASE_FIG + 1; /* Determine allocation unit. */
|
||||
if(szVal) {
|
||||
|
@ -2621,7 +2621,7 @@ VpAlloc(U_LONG mx, const char *szVal)
|
|||
|
||||
/* Skip all '_' after digit: 2006-6-30 */
|
||||
ni = 0;
|
||||
buf = rb_str_new(0,strlen(szVal)+1);
|
||||
buf = rb_str_tmp_new(strlen(szVal)+1);
|
||||
psz = RSTRING_PTR(buf);
|
||||
i = 0;
|
||||
ipn = 0;
|
||||
|
@ -2720,6 +2720,7 @@ VpAlloc(U_LONG mx, const char *szVal)
|
|||
vp->MaxPrec = mx; /* set max precision */
|
||||
VpSetZero(vp,sign);
|
||||
VpCtoV(vp, &(szVal[ipn]), ni, &(szVal[ipf]), nf, &(szVal[ipe]), ne);
|
||||
rb_str_resize(buf, 0);
|
||||
return vp;
|
||||
}
|
||||
|
||||
|
|
|
@ -698,4 +698,15 @@ class TestBigDecimal < Test::Unit::TestCase
|
|||
assert_equal(BigDecimal::SIGN_POSITIVE_ZERO, BigDecimal.new("1E-1" + "0" * 10000).sign)
|
||||
assert_equal(BigDecimal::SIGN_NEGATIVE_ZERO, BigDecimal.new("-1E-1" + "0" * 10000).sign)
|
||||
end
|
||||
|
||||
def test_gc
|
||||
bug3258 = '[ruby-dev:41213]'
|
||||
stress, GC.stress = GC.stress, true
|
||||
1000.times do |i|
|
||||
b = BigDecimal.new("1"+"0"*i).to_s
|
||||
assert_equal([1, "1", 10, i+1], b.split, bug3258)
|
||||
end
|
||||
ensure
|
||||
GC.stress = stress
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче