diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2012-02-23 21:17:47 +0100 |
---|---|---|
committer | Marc Glisse <marc.glisse@inria.fr> | 2012-02-23 21:17:47 +0100 |
commit | 2b06ef413348321424141880c23fea600940e25b (patch) | |
tree | d2f66feff6187bda4f7440776914199d7eb0d5b1 /mpz/setbit.c | |
parent | 8e1827335d45a049e434a2b095558f14dd4bf36f (diff) | |
download | gmp-2b06ef413348321424141880c23fea600940e25b.tar.gz |
Use the macros ALLOC etc to access the fields of mpz_t in mpz/*.
Test mpz_abs when it requires a reallocation.
Diffstat (limited to 'mpz/setbit.c')
-rw-r--r-- | mpz/setbit.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/mpz/setbit.c b/mpz/setbit.c index 990b1fb05..5b43ab6ab 100644 --- a/mpz/setbit.c +++ b/mpz/setbit.c @@ -24,8 +24,8 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ void mpz_setbit (mpz_ptr d, mp_bitcnt_t bit_index) { - mp_size_t dsize = d->_mp_size; - mp_ptr dp = d->_mp_d; + mp_size_t dsize = SIZ (d); + mp_ptr dp = PTR (d); mp_size_t limb_index; limb_index = bit_index / GMP_NUMB_BITS; @@ -34,7 +34,7 @@ mpz_setbit (mpz_ptr d, mp_bitcnt_t bit_index) if (limb_index < dsize) { dp[limb_index] |= (mp_limb_t) 1 << (bit_index % GMP_NUMB_BITS); - d->_mp_size = dsize; + SIZ (d) = dsize; } else { @@ -43,7 +43,7 @@ mpz_setbit (mpz_ptr d, mp_bitcnt_t bit_index) dp = MPZ_REALLOC (d, limb_index + 1); MPN_ZERO (dp + dsize, limb_index - dsize); dp[limb_index] = (mp_limb_t) 1 << (bit_index % GMP_NUMB_BITS); - d->_mp_size = limb_index + 1; + SIZ (d) = limb_index + 1; } } else @@ -78,7 +78,7 @@ mpz_setbit (mpz_ptr d, mp_bitcnt_t bit_index) do { dsize--; } while (dsize > 0 && dp[dsize-1] == 0); - d->_mp_size = -dsize; + SIZ (d) = -dsize; } } } @@ -100,7 +100,7 @@ mpz_setbit (mpz_ptr d, mp_bitcnt_t bit_index) dsize++; dp = MPZ_REALLOC (d, dsize); dp[i] = 1; - d->_mp_size = -dsize; + SIZ (d) = -dsize; fin:; } } @@ -109,7 +109,7 @@ mpz_setbit (mpz_ptr d, mp_bitcnt_t bit_index) mpn_decr_u (dp + limb_index, (mp_limb_t) 1 << (bit_index % GMP_NUMB_BITS)); dsize -= dp[dsize - 1] == 0; - d->_mp_size = -dsize; + SIZ (d) = -dsize; } } } |