summaryrefslogtreecommitdiff
path: root/mpz
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2016-12-28 18:39:40 +0100
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2016-12-28 18:39:40 +0100
commitbc7028c9cd73b6dc74f55c0972c2588717a8dd92 (patch)
treeeb3cf8b36ec47507b793c879985dc5139241eb98 /mpz
parent1e88b60e701eddf008f3bb4d8212761d79a90082 (diff)
downloadgmp-bc7028c9cd73b6dc74f55c0972c2588717a8dd92.tar.gz
Use MPZ_NEWALLOC and other macros result
Diffstat (limited to 'mpz')
-rw-r--r--mpz/divexact.c5
-rw-r--r--mpz/fdiv_qr_ui.c3
-rw-r--r--mpz/gcd_ui.c2
-rw-r--r--mpz/inp_str.c2
-rw-r--r--mpz/iset.c4
-rw-r--r--mpz/lucnum2_ui.c4
-rw-r--r--mpz/lucnum_ui.c2
-rw-r--r--mpz/mul_i.h2
-rw-r--r--mpz/n_pow_ui.c2
-rw-r--r--mpz/powm.c2
-rw-r--r--mpz/random2.c2
-rw-r--r--mpz/root.c2
-rw-r--r--mpz/rootrem.c4
-rw-r--r--mpz/set_f.c2
-rw-r--r--mpz/sqrtrem.c3
-rw-r--r--mpz/tdiv_r_ui.c2
16 files changed, 21 insertions, 22 deletions
diff --git a/mpz/divexact.c b/mpz/divexact.c
index 9c89de889..833681925 100644
--- a/mpz/divexact.c
+++ b/mpz/divexact.c
@@ -33,7 +33,6 @@ see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
-#include "longlong.h"
void
mpz_divexact (mpz_ptr quot, mpz_srcptr num, mpz_srcptr den)
@@ -73,7 +72,7 @@ mpz_divexact (mpz_ptr quot, mpz_srcptr num, mpz_srcptr den)
if (quot == num || quot == den)
qp = TMP_ALLOC_LIMBS (qn);
else
- qp = MPZ_REALLOC (quot, qn);
+ qp = MPZ_NEWALLOC (quot, qn);
np = PTR(num);
dp = PTR(den);
@@ -82,7 +81,7 @@ mpz_divexact (mpz_ptr quot, mpz_srcptr num, mpz_srcptr den)
MPN_NORMALIZE (qp, qn);
if (qp != PTR(quot))
- MPN_COPY (MPZ_REALLOC (quot, qn), qp, qn);
+ MPN_COPY (MPZ_NEWALLOC (quot, qn), qp, qn);
SIZ(quot) = (SIZ(num) ^ SIZ(den)) >= 0 ? qn : -qn;
diff --git a/mpz/fdiv_qr_ui.c b/mpz/fdiv_qr_ui.c
index 03184f769..984ca1c72 100644
--- a/mpz/fdiv_qr_ui.c
+++ b/mpz/fdiv_qr_ui.c
@@ -61,8 +61,7 @@ mpz_fdiv_qr_ui (mpz_ptr quot, mpz_ptr rem, mpz_srcptr dividend, unsigned long in
mp_ptr rp;
mp_size_t rn;
- MPZ_REALLOC (rem, 2);
- rp = PTR(rem);
+ rp = MPZ_REALLOC (rem, 2);
if (nn == 1) /* tdiv_qr requirements; tested above for 0 */
{
diff --git a/mpz/gcd_ui.c b/mpz/gcd_ui.c
index 4da942038..ee5bff81c 100644
--- a/mpz/gcd_ui.c
+++ b/mpz/gcd_ui.c
@@ -63,7 +63,7 @@ mpz_gcd_ui (mpz_ptr w, mpz_srcptr u, unsigned long int v)
{
if (u != w)
{
- MPZ_REALLOC (w, un);
+ MPZ_NEWALLOC (w, un);
MPN_COPY (PTR(w), PTR(u), un);
}
SIZ(w) = un;
diff --git a/mpz/inp_str.c b/mpz/inp_str.c
index ec3143bc8..df508c3f5 100644
--- a/mpz/inp_str.c
+++ b/mpz/inp_str.c
@@ -162,7 +162,7 @@ mpz_inp_str_nowhite (mpz_ptr x, FILE *stream, int base, int c, size_t nread)
else
{
LIMBS_PER_DIGIT_IN_BASE (xsize, str_size, base);
- MPZ_REALLOC (x, xsize);
+ MPZ_NEWALLOC (x, xsize);
/* Convert the byte array in base BASE to our bignum format. */
xsize = mpn_set_str (PTR (x), (unsigned char *) str, str_size, base);
diff --git a/mpz/iset.c b/mpz/iset.c
index adff8bb99..252cada29 100644
--- a/mpz/iset.c
+++ b/mpz/iset.c
@@ -42,9 +42,9 @@ mpz_init_set (mpz_ptr w, mpz_srcptr u)
size = ABS (usize);
ALLOC (w) = MAX (size, 1);
- PTR (w) = __GMP_ALLOCATE_FUNC_LIMBS (ALLOC (w));
+ wp = __GMP_ALLOCATE_FUNC_LIMBS (ALLOC (w));
- wp = PTR (w);
+ PTR (w) = wp;
up = PTR (u);
MPN_COPY (wp, up, size);
diff --git a/mpz/lucnum2_ui.c b/mpz/lucnum2_ui.c
index fd8238352..bdf69328a 100644
--- a/mpz/lucnum2_ui.c
+++ b/mpz/lucnum2_ui.c
@@ -63,8 +63,8 @@ mpz_lucnum2_ui (mpz_ptr ln, mpz_ptr lnsub1, unsigned long n)
size = MPN_FIB2_SIZE (n);
f1p = TMP_ALLOC_LIMBS (size);
- lp = MPZ_REALLOC (ln, size+1);
- l1p = MPZ_REALLOC (lnsub1, size+1);
+ lp = MPZ_NEWALLOC (ln, size+1);
+ l1p = MPZ_NEWALLOC (lnsub1, size+1);
size = mpn_fib2_ui (l1p, f1p, n);
diff --git a/mpz/lucnum_ui.c b/mpz/lucnum_ui.c
index 7ac09fe48..a13584bb4 100644
--- a/mpz/lucnum_ui.c
+++ b/mpz/lucnum_ui.c
@@ -76,7 +76,7 @@ mpz_lucnum_ui (mpz_ptr ln, unsigned long n)
since square or mul used below might need an extra limb over the true
size */
lalloc = MPN_FIB2_SIZE (n) + 2;
- lp = MPZ_REALLOC (ln, lalloc);
+ lp = MPZ_NEWALLOC (ln, lalloc);
TMP_MARK;
xalloc = lalloc;
diff --git a/mpz/mul_i.h b/mpz/mul_i.h
index 9f4c114aa..65c9c2ffc 100644
--- a/mpz/mul_i.h
+++ b/mpz/mul_i.h
@@ -96,7 +96,7 @@ FUNCTION (mpz_ptr prod, mpz_srcptr mult,
tp[size + 1] = cy;
size += 2;
MPN_NORMALIZE_NOT_ZERO (tp, size); /* too general, need to trim one or two limb */
- pp = MPZ_REALLOC (prod, size);
+ pp = MPZ_NEWALLOC (prod, size);
MPN_COPY (pp, tp, size);
TMP_FREE;
}
diff --git a/mpz/n_pow_ui.c b/mpz/n_pow_ui.c
index c0d643d63..cf293f540 100644
--- a/mpz/n_pow_ui.c
+++ b/mpz/n_pow_ui.c
@@ -371,7 +371,7 @@ mpz_n_pow_ui (mpz_ptr r, mp_srcptr bp, mp_size_t bsize, unsigned long int e)
ralloc = (bsize*GMP_NUMB_BITS - cnt + GMP_NAIL_BITS) * e / GMP_NUMB_BITS + 5;
TRACE (printf ("ralloc %ld, from bsize=%ld blimb=0x%lX cnt=%d\n",
ralloc, bsize, blimb, cnt));
- rp = MPZ_REALLOC (r, ralloc + rtwos_limbs);
+ rp = MPZ_NEWALLOC (r, ralloc + rtwos_limbs);
/* Low zero limbs resulting from powers of 2. */
MPN_ZERO (rp, rtwos_limbs);
diff --git a/mpz/powm.c b/mpz/powm.c
index dbfe1a24d..8433bbc57 100644
--- a/mpz/powm.c
+++ b/mpz/powm.c
@@ -274,7 +274,7 @@ mpz_powm (mpz_ptr r, mpz_srcptr b, mpz_srcptr e, mpz_srcptr m)
}
ret:
- MPZ_REALLOC (r, rn);
+ MPZ_NEWALLOC (r, rn);
SIZ(r) = rn;
MPN_COPY (PTR(r), rp, rn);
diff --git a/mpz/random2.c b/mpz/random2.c
index e9c5ee10a..863dc4876 100644
--- a/mpz/random2.c
+++ b/mpz/random2.c
@@ -41,7 +41,7 @@ mpz_random2 (mpz_ptr x, mp_size_t size)
abs_size = ABS (size);
if (abs_size != 0)
{
- xp = MPZ_REALLOC (x, abs_size);
+ xp = MPZ_NEWALLOC (x, abs_size);
mpn_random2 (xp, abs_size);
}
diff --git a/mpz/root.c b/mpz/root.c
index d83d00ee6..7119bbc3a 100644
--- a/mpz/root.c
+++ b/mpz/root.c
@@ -64,7 +64,7 @@ mpz_root (mpz_ptr root, mpz_srcptr u, unsigned long int nth)
/* FIXME: Perhaps disallow root == NULL */
if (root != NULL && u != root)
- rootp = MPZ_REALLOC (root, rootn);
+ rootp = MPZ_NEWALLOC (root, rootn);
else
rootp = TMP_ALLOC_LIMBS (rootn);
diff --git a/mpz/rootrem.c b/mpz/rootrem.c
index e9a7f0b2b..67953dbe6 100644
--- a/mpz/rootrem.c
+++ b/mpz/rootrem.c
@@ -65,12 +65,12 @@ mpz_rootrem (mpz_ptr root, mpz_ptr rem, mpz_srcptr u, unsigned long int nth)
/* FIXME: Perhaps disallow root == NULL */
if (root != NULL && u != root)
- rootp = MPZ_REALLOC (root, rootn);
+ rootp = MPZ_NEWALLOC (root, rootn);
else
rootp = TMP_ALLOC_LIMBS (rootn);
if (u != rem)
- remp = MPZ_REALLOC (rem, un);
+ remp = MPZ_NEWALLOC (rem, un);
else
remp = TMP_ALLOC_LIMBS (un);
diff --git a/mpz/set_f.c b/mpz/set_f.c
index f66501e4e..43d0fc802 100644
--- a/mpz/set_f.c
+++ b/mpz/set_f.c
@@ -46,7 +46,7 @@ mpz_set_f (mpz_ptr w, mpf_srcptr u)
return;
}
- wp = MPZ_REALLOC (w, exp);
+ wp = MPZ_NEWALLOC (w, exp);
up = PTR(u);
size = SIZ (u);
diff --git a/mpz/sqrtrem.c b/mpz/sqrtrem.c
index 6acd5a67f..a580d9591 100644
--- a/mpz/sqrtrem.c
+++ b/mpz/sqrtrem.c
@@ -48,7 +48,8 @@ mpz_sqrtrem (mpz_ptr root, mpz_ptr rem, mpz_srcptr op)
return;
}
- rem_ptr = MPZ_REALLOC (rem, op_size);
+ /* No-op if rem == op */
+ rem_ptr = MPZ_NEWALLOC (rem, op_size);
/* The size of the root is accurate after this simple calculation. */
root_size = (op_size + 1) / 2;
diff --git a/mpz/tdiv_r_ui.c b/mpz/tdiv_r_ui.c
index 75a43f745..f3da8efae 100644
--- a/mpz/tdiv_r_ui.c
+++ b/mpz/tdiv_r_ui.c
@@ -67,7 +67,7 @@ mpz_tdiv_r_ui (mpz_ptr rem, mpz_srcptr dividend, unsigned long int divisor)
return rl;
}
- rp = MPZ_REALLOC (rem, 2);
+ rp = MPZ_NEWALLOC (rem, 2);
TMP_MARK;
dp[0] = divisor & GMP_NUMB_MASK;