Lazy mpz allocation

Niels Möller nisse at
Wed May 4 13:32:42 UTC 2016

Marc Glisse <marc.glisse at> writes:

> That looks pretty much like the copy-on-write thing you and Marco were
> discussing last year

Exactly, thanks for digging it up. And quoting Marco
here's the main drawback

: E.g. mpz_combit starts with:
:   if (limb_index + 1 < SIZ(x)) {
:     PTR(x)[limb_index] ^= bit;
:     return;
:   }
: If we allow the ALLOC(x)==0 && SIZ(x) != 0 case, we need to insert a check
: also in the simpler cases...

Not sure how painful it would be to fix copy-on-write in all those


Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

More information about the gmp-devel mailing list