Question re mpf_get_str

Torbjorn Granlund tg at
Mon Jan 19 22:24:20 CET 2009

"Bruce M. Axtens" <bruce.axtens at> writes:

  According to the v4.2.4 manual, mpf_get_str can be called with a NULL in
  the first argument:
    If str is NULL, the result string is allocated using the current
    allocation function (see
    Chapter 14 [Custom Allocation], page 85). The block will be
    strlen(str)+1 bytes, that
    being exactly enough for the string and null-terminator.
  What I'd like to know is whether this block needs to be freed, and if so,
  how? Is it simply a case of
    free( ptr, strlen(ptr)+1);
That depends entirely on how the free() function you're using on your
system expects to be called.  The C standard library function surely
doesn't take any size argument.


More information about the gmp-discuss mailing list