summaryrefslogtreecommitdiff
path: root/mpz/iset_ui.c
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2012-03-26 08:01:31 +0200
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2012-03-26 08:01:31 +0200
commit50ce0b619a3df7e3f7970c03ec164f0a894a505f (patch)
tree93cf3d20cc7e8899db4193239ee04980a32a1051 /mpz/iset_ui.c
parent83acd3efba74519ff859162b1f4105d4698d468c (diff)
downloadgmp-50ce0b619a3df7e3f7970c03ec164f0a894a505f.tar.gz
mpz/iset_ui.c: Don't realloc.
Diffstat (limited to 'mpz/iset_ui.c')
-rw-r--r--mpz/iset_ui.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/mpz/iset_ui.c b/mpz/iset_ui.c
index 815b7379d..7eed1c165 100644
--- a/mpz/iset_ui.c
+++ b/mpz/iset_ui.c
@@ -27,20 +27,23 @@ mpz_init_set_ui (mpz_ptr dest, unsigned long int val)
{
mp_size_t size;
- ALLOC (dest) = 1;
- PTR (dest) = (mp_ptr) (*__gmp_allocate_func) (BYTES_PER_MP_LIMB);
-
- PTR (dest)[0] = val & GMP_NUMB_MASK;
- size = val != 0;
-
#if BITS_PER_ULONG > GMP_NUMB_BITS /* avoid warnings about shift amount */
if (val > GMP_NUMB_MAX)
{
- MPZ_REALLOC (dest, 2);
+ ALLOC (dest) = 2;
+ PTR (dest) = (mp_ptr) (*__gmp_allocate_func) (BYTES_PER_MP_LIMB*2);
PTR (dest)[1] = val >> GMP_NUMB_BITS;
size = 2;
}
+ else
#endif
+ {
+ ALLOC (dest) = 1;
+ PTR (dest) = (mp_ptr) (*__gmp_allocate_func) (BYTES_PER_MP_LIMB);
+
+ size = val != 0;
+ }
+ PTR (dest)[0] = val & GMP_NUMB_MASK;
SIZ (dest) = size;
}