3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-08 18:31:49 +00:00

Fixed memory leak

This commit is contained in:
Christoph M. Wintersteiger 2015-01-22 18:43:23 +00:00
parent c3ff342bea
commit 034e4f469e
2 changed files with 6 additions and 5 deletions

View file

@ -696,6 +696,7 @@ extern "C" {
RESET_ERROR_CODE();
ast_manager & m = mk_c(c)->m();
mpf_manager & mpfm = mk_c(c)->fpa_util().fm();
unsynch_mpz_manager & mpzm = mpfm.mpz_manager();
unsynch_mpq_manager & mpqm = mpfm.mpq_manager();
fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(mk_c(c)->get_fpa_fid());
scoped_mpf val(mpfm);
@ -709,7 +710,9 @@ extern "C" {
}
unsigned sbits = val.get().get_sbits();
scoped_mpq q(mpqm);
mpqm.set(q, mpfm.sig_normalized(val));
scoped_mpz sn(mpzm);
mpfm.sig_normalized(val, sn);
mpqm.set(q, sn);
mpqm.div(q, mpfm.m_powers2(sbits - 1), q);
std::stringstream ss;
mpqm.display_decimal(ss, q, sbits);

View file

@ -146,14 +146,12 @@ public:
bool sgn(mpf const & x) const { return x.sign; }
const mpz & sig(mpf const & x) const { return x.significand; }
mpz sig_normalized(mpf const & x) {
void sig_normalized(mpf const & x, mpz & res) {
mpf t;
set(t, x);
unpack(t, true);
mpz r;
mpz_manager().set(r, t.significand);
mpz_manager().set(res, t.significand);
del(t);
return r;
}
const mpf_exp_t & exp(mpf const & x) const { return x.exponent; }
mpf_exp_t exp_normalized(mpf const & x) {