summaryrefslogtreecommitdiff
path: root/mpz/tdiv_r_2exp.c
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2012-02-23 21:17:47 +0100
committerMarc Glisse <marc.glisse@inria.fr>2012-02-23 21:17:47 +0100
commit2b06ef413348321424141880c23fea600940e25b (patch)
treed2f66feff6187bda4f7440776914199d7eb0d5b1 /mpz/tdiv_r_2exp.c
parent8e1827335d45a049e434a2b095558f14dd4bf36f (diff)
downloadgmp-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/tdiv_r_2exp.c')
-rw-r--r--mpz/tdiv_r_2exp.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/mpz/tdiv_r_2exp.c b/mpz/tdiv_r_2exp.c
index 3828ff130..8728c809d 100644
--- a/mpz/tdiv_r_2exp.c
+++ b/mpz/tdiv_r_2exp.c
@@ -23,10 +23,10 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
void
mpz_tdiv_r_2exp (mpz_ptr res, mpz_srcptr in, mp_bitcnt_t cnt)
{
- mp_size_t in_size = ABS (in->_mp_size);
+ mp_size_t in_size = ABSIZ (in);
mp_size_t res_size;
mp_size_t limb_cnt = cnt / GMP_NUMB_BITS;
- mp_srcptr in_ptr = in->_mp_d;
+ mp_srcptr in_ptr = PTR (in);
if (in_size > limb_cnt)
{
@@ -37,18 +37,16 @@ mpz_tdiv_r_2exp (mpz_ptr res, mpz_srcptr in, mp_bitcnt_t cnt)
if (x != 0)
{
res_size = limb_cnt + 1;
- if (res->_mp_alloc < res_size)
- _mpz_realloc (res, res_size);
+ MPZ_REALLOC (res, res_size);
- res->_mp_d[limb_cnt] = x;
+ PTR (res)[limb_cnt] = x;
}
else
{
res_size = limb_cnt;
MPN_NORMALIZE (in_ptr, res_size);
- if (res->_mp_alloc < res_size)
- _mpz_realloc (res, res_size);
+ MPZ_REALLOC (res, res_size);
limb_cnt = res_size;
}
@@ -58,13 +56,12 @@ mpz_tdiv_r_2exp (mpz_ptr res, mpz_srcptr in, mp_bitcnt_t cnt)
/* The input operand is smaller than 2**CNT. We perform a no-op,
apart from that we might need to copy IN to RES. */
res_size = in_size;
- if (res->_mp_alloc < res_size)
- _mpz_realloc (res, res_size);
+ MPZ_REALLOC (res, res_size);
limb_cnt = res_size;
}
if (res != in)
- MPN_COPY (res->_mp_d, in->_mp_d, limb_cnt);
- res->_mp_size = in->_mp_size >= 0 ? res_size : -res_size;
+ MPN_COPY (PTR (res), PTR (in), limb_cnt);
+ SIZ (res) = SIZ (in) >= 0 ? res_size : -res_size;
}