summaryrefslogtreecommitdiff
path: root/mpz
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2012-02-20 20:19:49 +0100
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2012-02-20 20:19:49 +0100
commiteb9ede1bd76ce4a993dbade89666732734d25c33 (patch)
tree09597cfada706df5203cb15529b395db3c84c453 /mpz
parenta86268eceacfd4f6cd9dfca1341d795ffe21223d (diff)
downloadgmp-eb9ede1bd76ce4a993dbade89666732734d25c33.tar.gz
mpz/and.c: Use TMP_ALLOC_LIMBS_2.
Diffstat (limited to 'mpz')
-rw-r--r--mpz/and.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/mpz/and.c b/mpz/and.c
index 905e77b82..5d50c769e 100644
--- a/mpz/and.c
+++ b/mpz/and.c
@@ -70,9 +70,8 @@ mpz_and (mpz_ptr res, mpz_srcptr op1, mpz_srcptr op2)
{
if (op2_size < 0)
{
- mp_ptr opx;
+ mp_ptr opx, opy;
mp_limb_t cy;
- mp_size_t res_alloc;
/* Both operands are negative, so will be the result.
-((-OP1) & (-OP2)) = -(~(OP1 - 1) & ~(OP2 - 1)) =
@@ -90,17 +89,14 @@ mpz_and (mpz_ptr res, mpz_srcptr op1, mpz_srcptr op2)
if (op1_size > op2_size)
MPN_SRCPTR_SWAP (op1_ptr, op1_size, op2_ptr, op2_size);
- res_alloc = 1 + op2_size;
-
- opx = TMP_ALLOC_LIMBS (op1_size);
+ TMP_ALLOC_LIMBS_2 (opx, op1_size, opy, op2_size);
mpn_sub_1 (opx, op1_ptr, op1_size, (mp_limb_t) 1);
op1_ptr = opx;
- opx = TMP_ALLOC_LIMBS (op2_size);
- mpn_sub_1 (opx, op2_ptr, op2_size, (mp_limb_t) 1);
- op2_ptr = opx;
+ mpn_sub_1 (opy, op2_ptr, op2_size, (mp_limb_t) 1);
+ op2_ptr = opy;
- res_ptr = MPZ_REALLOC (res, res_alloc);
+ res_ptr = MPZ_REALLOC (res, 1 + op2_size);
/* Don't re-read OP1_PTR and OP2_PTR. They point to temporary
space--never to the space PTR(res) used to point to before
reallocation. */