Lazy mpz allocation

Marco Bodrato bodrato at
Fri Apr 20 06:17:42 UTC 2018


Il Gio, 19 Aprile 2018 4:37 pm, Marc Glisse ha scritto:
> I finally pushed it. It seemed unsafe to keep mpq unaware of lazy
> allocation, in case people start swapping the numerator of a rational with
> a lazy 0 integer or something like that.

If we fear swaps, then ... what about swapping the deoniminator?

Should we support a code like:

  mpz_init (saved_denominator);
  mpz_swap (saved_denominator, mpq_denref(rational));
  /* Code overwriting rational*/


If yes, a larger patch is needed, I attach a proposal.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: gmp.diff
Type: text/x-patch
Size: 4775 bytes
Desc: not available
URL: <>

More information about the gmp-devel mailing list