summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTorbjorn Granlund <tg@gmplib.org>2020-04-28 15:27:23 +0200
committerTorbjorn Granlund <tg@gmplib.org>2020-04-28 15:27:23 +0200
commitffcb0b6177bca40882b14a6c0ea027fded949db4 (patch)
tree6e1ad88b9f81b9009442fea5dd7e9c4b3828c54e /tests
parent71361a056baa4abf36926dce95e99780913ade9a (diff)
downloadgmp-ffcb0b6177bca40882b14a6c0ea027fded949db4.tar.gz
Avoid dummy-reallocating to large mpz_clobber-generated sizes.
* tests/mpz/reuse.c (realloc_if_reducing): New function. (INVOKE_RRS, etc): Use realloc_if_reducing.
Diffstat (limited to 'tests')
-rw-r--r--tests/mpz/reuse.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/tests/mpz/reuse.c b/tests/mpz/reuse.c
index f057a9672..30a5bab5d 100644
--- a/tests/mpz/reuse.c
+++ b/tests/mpz/reuse.c
@@ -6,8 +6,8 @@
mpz_mul_si
mpz_addmul_ui (should this really allow a+=a*c?)
-Copyright 1996, 1999-2002, 2009, 2012, 2013, 2016 Free Software Foundation,
-Inc.
+Copyright 1996, 1999-2002, 2009, 2012, 2013, 2016, 2020 Free Software
+Foundation, Inc.
This file is part of the GNU MP Library test suite.
@@ -174,26 +174,33 @@ struct {
} while (0)
+void
+realloc_if_reducing (mpz_ptr r)
+{
+ if (ABSIZ(r) < ALLOC(r))
+ _mpz_realloc (r, ABSIZ(r));
+}
+
#define INVOKE_RRS(desc,r1,r2,i1) \
do { \
- if (pass & 1) _mpz_realloc (r1, ABSIZ(r1)); \
- if (pass & 2) _mpz_realloc (r2, ABSIZ(r2)); \
+ if (pass & 1) realloc_if_reducing (r1); \
+ if (pass & 2) realloc_if_reducing (r2); \
(desc).fptr (r1, r2, i1); \
} while (0)
#define INVOKE_RS(desc,r1,i1) \
do { \
- if (pass & 1) _mpz_realloc (r1, ABSIZ(r1)); \
+ if (pass & 1) realloc_if_reducing (r1); \
(desc).fptr (r1, i1); \
} while (0)
#define INVOKE_RRSS(desc,r1,r2,i1,i2) \
do { \
- if (pass & 1) _mpz_realloc (r1, ABSIZ(r1)); \
- if (pass & 2) _mpz_realloc (r2, ABSIZ(r2)); \
+ if (pass & 1) realloc_if_reducing (r1); \
+ if (pass & 2) realloc_if_reducing (r2); \
(desc).fptr (r1, r2, i1, i2); \
} while (0)
#define INVOKE_RSS(desc,r1,i1,i2) \
do { \
- if (pass & 1) _mpz_realloc (r1, ABSIZ(r1)); \
+ if (pass & 1) realloc_if_reducing (r1); \
(desc).fptr (r1, i1, i2); \
} while (0)
@@ -204,7 +211,6 @@ main (int argc, char **argv)
unsigned int pass, reps = 400;
mpz_t in1, in2, in3;
unsigned long int in2i;
- mp_size_t size;
mpz_t res1, res2, res3;
mpz_t ref1, ref2, ref3;
mpz_t t;
@@ -763,16 +769,16 @@ void
dump (const char *name, mpz_t in1, mpz_t in2, mpz_t in3)
{
printf ("failure in %s (", name);
- 0 && mpz_out_str (stdout, -16, in1);
+ mpz_out_str (stdout, -16, in1);
if (in2 != NULL)
{
printf (" ");
- 0 && mpz_out_str (stdout, -16, in2);
+ mpz_out_str (stdout, -16, in2);
}
if (in3 != NULL)
{
printf (" ");
- 0 && mpz_out_str (stdout, -16, in3);
+ mpz_out_str (stdout, -16, in3);
}
printf (")\n");
}