[ruby/bigdecimal] Keep obj-to-Real link when VpReallocReal returns different pointer
https://github.com/ruby/bigdecimal/commit/252748de17
This commit is contained in:
parent
75f552e973
commit
38e98cbdb7
@ -869,7 +869,18 @@ VpCreateRbObject(size_t mx, const char *str, bool raise_exception)
|
||||
}
|
||||
|
||||
#define VpAllocReal(prec) (Real *)VpMemAlloc(offsetof(Real, frac) + (prec) * sizeof(DECDIG))
|
||||
#define VpReallocReal(ptr, prec) (Real *)VpMemRealloc((ptr), offsetof(Real, frac) + (prec) * sizeof(DECDIG))
|
||||
|
||||
static Real *
|
||||
VpReallocReal(Real *pv, size_t prec)
|
||||
{
|
||||
VALUE obj = pv ? pv->obj : 0;
|
||||
Real *new_pv = (Real *)VpMemRealloc(pv, offsetof(Real, frac) + prec * sizeof(DECDIG));
|
||||
if (obj) {
|
||||
new_pv->obj = 0;
|
||||
BigDecimal_wrap_struct(obj, new_pv);
|
||||
}
|
||||
return new_pv;
|
||||
}
|
||||
|
||||
static Real *
|
||||
VpCopy(Real *pv, Real const* const x)
|
||||
|
Loading…
x
Reference in New Issue
Block a user