Memory leak in mpf_get_str()

Carlos Carreras carreras at die.upm.es
Sun Nov 11 17:31:54 CET 2007


Hello,

I am new to this list so I dont' know if this has been discussed before.
If I use mpf_get_str() to obtain a string with all the significant
digits, valgrind detects a memory leak. Running 'valgrind
--leak-check=full' after compiling the following code indicates a leak
of 3 bytes definitely lost.
If the initilization uses the double 2.1, the leak is of 22 bytes.

#include<gmp.h>
int main() {
  mpf_set_default_prec(64);
  mpf_t n;
  mpf_init_set_si(n, -1);
  mp_exp_t e;
  mpf_get_str(NULL, &e, 10, 0, n);
  mpf_clear(n);
  return 0;
}

What am I doing wrong? How can I get around this? Thanks!

Carlos


More information about the gmp-discuss mailing list