summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2023-02-21 14:16:45 +0100
committergit <svn-admin@ruby-lang.org>2023-02-21 14:24:13 +0000
commit7b768e43354391098929adf97a593fae79d5fc2e (patch)
treea230338675e67a937182f9fdb888f567f44865f8 /ext
parent5077cc2be68a29339748b50b2346285f545392ea (diff)
downloadruby-7b768e43354391098929adf97a593fae79d5fc2e.tar.gz
[ruby/bigdecimal] Move RB_GC_GUARD() at the end, like in BigMath_s_exp()
https://github.com/ruby/bigdecimal/commit/b66ef9fbb5
Diffstat (limited to 'ext')
-rw-r--r--ext/bigdecimal/bigdecimal.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index b4e32c709e..ae37c65f4c 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -4144,12 +4144,9 @@ get_vp_value:
one = VpCheckGetValue(NewOneWrapLimited(1, 1));
two = VpCheckGetValue(VpCreateRbObject(1, "2", true));
- RB_GC_GUARD(one);
- RB_GC_GUARD(two);
n = prec + BIGDECIMAL_DOUBLE_FIGURES;
vn = SSIZET2NUM(n);
- RB_GC_GUARD(vn);
expo = VpExponent10(vx);
if (expo < 0 || expo >= 3) {
char buf[DECIMAL_SIZE_OF_BITS(SIZEOF_VALUE * CHAR_BIT) + 4];
@@ -4164,9 +4161,6 @@ get_vp_value:
x2 = BigDecimal_mult2(x, x, vn);
y = x;
d = y;
- RB_GC_GUARD(x2);
- RB_GC_GUARD(y);
- RB_GC_GUARD(d);
i = 1;
while (!VpIsZero((Real*)DATA_PTR(d))) {
SIGNED_VALUE const ey = VpExponent10(DATA_PTR(y));
@@ -4194,6 +4188,13 @@ get_vp_value:
y = BigDecimal_add(y, dy);
}
+ RB_GC_GUARD(one);
+ RB_GC_GUARD(two);
+ RB_GC_GUARD(vn);
+ RB_GC_GUARD(x2);
+ RB_GC_GUARD(y);
+ RB_GC_GUARD(d);
+
return y;
}