From 2b06ef413348321424141880c23fea600940e25b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 23 Feb 2012 21:17:47 +0100 Subject: Use the macros ALLOC etc to access the fields of mpz_t in mpz/*. Test mpz_abs when it requires a reallocation. --- mpz/setbit.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'mpz/setbit.c') 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; } } } -- cgit v1.2.1