diff options
author | Kevin Ryde <user42@zip.com.au> | 2001-11-26 23:55:11 +0100 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2001-11-26 23:55:11 +0100 |
commit | 7cee3a1d860b68f897577b7ba70f75f7e012380a (patch) | |
tree | 52869d8a39198a09f6d680bde4db594c6ac1f593 /mpz | |
parent | 9fc22b141dbd87fea44c0ff44fa4746557c14be0 (diff) | |
download | gmp-7cee3a1d860b68f897577b7ba70f75f7e012380a.tar.gz |
More of:
* mpz/init2.c, mpz/realloc2.c: New files.
Diffstat (limited to 'mpz')
-rw-r--r-- | mpz/realloc2.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/mpz/realloc2.c b/mpz/realloc2.c index 77e3a1e60..20f3ff1b8 100644 --- a/mpz/realloc2.c +++ b/mpz/realloc2.c @@ -26,9 +26,13 @@ void mpz_realloc2 (mpz_ptr x, unsigned long bits) { mp_size_t new_limbs, old_limbs; + new_limbs = (bits + BITS_PER_MP_LIMB-1) / BITS_PER_MP_LIMB; new_limbs = MAX (new_limbs, 1); - new_limbs = MAX (new_limbs, ABSIZ(x)); + + if (ABSIZ(m) > new_limbs) + SIZ(m) = 0; + old_limbs = ALLOC(x); ALLOC(x) = new_limbs; PTR(x) = __GMP_REALLOCATE_FUNC_LIMBS (PTR(x), old_limbs, new_limbs); |