Lazy mpz allocation

Torbjörn Granlund tg at gmplib.org
Tue Sep 1 07:35:01 UTC 2015


nisse at lysator.liu.se (Niels Möller) writes:

  Sure, but we could do
  
    static const mp_limb_t dummy_limb = 0xc0dedead;
  
    void mpz_init (mpz_t x)
    {
      x->_mp_size = x->_mp_alloc = 0;
      x->_mp_d = &dummy_limb;
    }
  
  It still represents the number zero, it's just that _mp_d[0] points to a
  dummy limb which happens to be far from zero.
  
Sorry, I misunderstood your proposal.

-- 
Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-devel mailing list