mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/bigdecimal/bigdecimal.c (VpAllocReal): reduce extra frac.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5fce7630c7
commit
d0b2816d02
2 changed files with 12 additions and 6 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Fri Dec 2 15:48:08 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/bigdecimal/bigdecimal.c (VpAllocReal): reduce extra frac.
|
||||||
|
|
||||||
Fri Dec 2 15:41:24 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Dec 2 15:41:24 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* configure.in: check whether -pie or -Wl,-pie is valid as
|
* configure.in: check whether -pie or -Wl,-pie is valid as
|
||||||
|
|
|
@ -554,6 +554,8 @@ VpCreateRbObject(size_t mx, const char *str)
|
||||||
return pv;
|
return pv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define VpAllocReal(prec) (Real *)VpMemAlloc(offsetof(Real, frac) + (prec) * sizeof(BDIGIT))
|
||||||
|
|
||||||
static Real *
|
static Real *
|
||||||
VpDup(Real const* const x)
|
VpDup(Real const* const x)
|
||||||
{
|
{
|
||||||
|
@ -561,7 +563,7 @@ VpDup(Real const* const x)
|
||||||
|
|
||||||
assert(x != NULL);
|
assert(x != NULL);
|
||||||
|
|
||||||
pv = VpMemAlloc(sizeof(Real) + x->MaxPrec * sizeof(BDIGIT));
|
pv = VpAllocReal(x->MaxPrec);
|
||||||
pv->MaxPrec = x->MaxPrec;
|
pv->MaxPrec = x->MaxPrec;
|
||||||
pv->Prec = x->Prec;
|
pv->Prec = x->Prec;
|
||||||
pv->exponent = x->exponent;
|
pv->exponent = x->exponent;
|
||||||
|
@ -3576,7 +3578,7 @@ VpAlloc(size_t mx, const char *szVal)
|
||||||
/* necessary to be able to store */
|
/* necessary to be able to store */
|
||||||
/* at least mx digits. */
|
/* at least mx digits. */
|
||||||
/* szVal==NULL ==> allocate zero value. */
|
/* szVal==NULL ==> allocate zero value. */
|
||||||
vp = (Real *) VpMemAlloc(sizeof(Real) + mx * sizeof(BDIGIT));
|
vp = VpAllocReal(mx);
|
||||||
/* xmalloc() alway returns(or throw interruption) */
|
/* xmalloc() alway returns(or throw interruption) */
|
||||||
vp->MaxPrec = mx; /* set max precision */
|
vp->MaxPrec = mx; /* set max precision */
|
||||||
VpSetZero(vp,1); /* initialize vp to zero. */
|
VpSetZero(vp,1); /* initialize vp to zero. */
|
||||||
|
@ -3609,19 +3611,19 @@ VpAlloc(size_t mx, const char *szVal)
|
||||||
/* Check on Inf & NaN */
|
/* Check on Inf & NaN */
|
||||||
if (StrCmp(szVal, SZ_PINF) == 0 ||
|
if (StrCmp(szVal, SZ_PINF) == 0 ||
|
||||||
StrCmp(szVal, SZ_INF) == 0 ) {
|
StrCmp(szVal, SZ_INF) == 0 ) {
|
||||||
vp = (Real *) VpMemAlloc(sizeof(Real) + sizeof(BDIGIT));
|
vp = VpAllocReal(1);
|
||||||
vp->MaxPrec = 1; /* set max precision */
|
vp->MaxPrec = 1; /* set max precision */
|
||||||
VpSetPosInf(vp);
|
VpSetPosInf(vp);
|
||||||
return vp;
|
return vp;
|
||||||
}
|
}
|
||||||
if (StrCmp(szVal, SZ_NINF) == 0) {
|
if (StrCmp(szVal, SZ_NINF) == 0) {
|
||||||
vp = (Real *) VpMemAlloc(sizeof(Real) + sizeof(BDIGIT));
|
vp = VpAllocReal(1);
|
||||||
vp->MaxPrec = 1; /* set max precision */
|
vp->MaxPrec = 1; /* set max precision */
|
||||||
VpSetNegInf(vp);
|
VpSetNegInf(vp);
|
||||||
return vp;
|
return vp;
|
||||||
}
|
}
|
||||||
if (StrCmp(szVal, SZ_NaN) == 0) {
|
if (StrCmp(szVal, SZ_NaN) == 0) {
|
||||||
vp = (Real *) VpMemAlloc(sizeof(Real) + sizeof(BDIGIT));
|
vp = VpAllocReal(1);
|
||||||
vp->MaxPrec = 1; /* set max precision */
|
vp->MaxPrec = 1; /* set max precision */
|
||||||
VpSetNaN(vp);
|
VpSetNaN(vp);
|
||||||
return vp;
|
return vp;
|
||||||
|
@ -3679,7 +3681,7 @@ VpAlloc(size_t mx, const char *szVal)
|
||||||
if (mx <= 0) mx = 1;
|
if (mx <= 0) mx = 1;
|
||||||
nalloc = Max(nalloc, mx);
|
nalloc = Max(nalloc, mx);
|
||||||
mx = nalloc;
|
mx = nalloc;
|
||||||
vp = (Real *) VpMemAlloc(sizeof(Real) + mx * sizeof(BDIGIT));
|
vp = VpAllocReal(mx);
|
||||||
/* xmalloc() alway returns(or throw interruption) */
|
/* xmalloc() alway returns(or throw interruption) */
|
||||||
vp->MaxPrec = mx; /* set max precision */
|
vp->MaxPrec = mx; /* set max precision */
|
||||||
VpSetZero(vp, sign);
|
VpSetZero(vp, sign);
|
||||||
|
|
Loading…
Reference in a new issue