summaryrefslogtreecommitdiff
path: root/mpz/aors_ui.h
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2013-02-14 12:32:56 +0100
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2013-02-14 12:32:56 +0100
commit0f467c04d5940f1171e2672c66b96347cd081824 (patch)
tree61d02d1dd87a143a58e41011e98f8cda126b76f2 /mpz/aors_ui.h
parente9480d42977e293e58978b36c08c16827d62aef3 (diff)
downloadgmp-0f467c04d5940f1171e2672c66b96347cd081824.tar.gz
mpz/aors_ui.h: No realloc if size was zero.
Diffstat (limited to 'mpz/aors_ui.h')
-rw-r--r--mpz/aors_ui.h21
1 files changed, 10 insertions, 11 deletions
diff --git a/mpz/aors_ui.h b/mpz/aors_ui.h
index e46726747..6437cf370 100644
--- a/mpz/aors_ui.h
+++ b/mpz/aors_ui.h
@@ -1,8 +1,8 @@
/* mpz_add_ui, mpz_sub_ui -- Add or subtract an mpz_t and an unsigned
one-word integer.
-Copyright 1991, 1993, 1994, 1996, 1999, 2000, 2001, 2002, 2004, 2012 Free
-Software Foundation, Inc.
+Copyright 1991, 1993, 1994, 1996, 1999, 2000, 2001, 2002, 2004, 2012,
+2013 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -67,22 +67,21 @@ FUNCTION (mpz_ptr w, mpz_srcptr u, unsigned long int vval)
#endif
usize = SIZ (u);
+ if (usize == 0)
+ {
+ PTR (w)[0] = vval;
+ SIZ (w) = VARIATION_NEG (vval != 0);
+ return;
+ }
+
abs_usize = ABS (usize);
/* If not space for W (and possible carry), increase space. */
- wsize = abs_usize + 1;
- wp = MPZ_REALLOC (w, wsize);
+ wp = MPZ_REALLOC (w, abs_usize + 1);
/* These must be after realloc (U may be the same as W). */
up = PTR (u);
- if (abs_usize == 0)
- {
- wp[0] = vval;
- SIZ (w) = VARIATION_NEG (vval != 0);
- return;
- }
-
if (usize VARIATION_CMP 0)
{
mp_limb_t cy;