gmp

Henry Cejtin henry@sourcelight.com
Tue, 22 Jan 2002 19:24:58 -0600


No, there is no space leak (I think), but temporary space is gotten using
malloc.  It is returned before mpz_gcd() returns.  This is the goofyness of
mpn_gcd() which gets temporary space.
This means that, for instance, you could die with out of space in malloc().
Also it could be slow since malloc() will have to look around for the space.
A better solution would be to figure out the amount of temporary space
needed and get it from the heap along with the space for the result.  The
problem is that you would still either need your own copy of mpn_gcd() or else
you could try to play some game over-riding the allocator that it calls (which
can be done) and then have it return space that you got from the heap.