Lazy mpz allocation

Marco Bodrato bodrato at mail.dm.unipi.it
Sun Sep 27 05:51:37 UTC 2015


Ciao,

Il Mar, 1 Settembre 2015 6:46 am, Marco Bodrato ha scritto:
> I think that the condition to distinguish mpzs that where not allocated
> yet should be ALLOC(x)==0. As a consequence, MPZ_ROINIT_N can be the
> interface for initialising you ask for.
> I'd like a sort of "copy-on-write" interface, that allocates the needed

I looked into the code and realised that my proposal requires an
MPZ_REALLOC or if(ALLOC(x)==0) branch in ANY place where we write into an
mpz_t. 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...

Regards,
m

-- 
http://bodrato.it/papers/



More information about the gmp-devel mailing list