diff options
author | Kevin Ryde <user42@zip.com.au> | 2001-11-24 01:36:18 +0100 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2001-11-24 01:36:18 +0100 |
commit | f8926b5eb5dfb44a3646b43768d92806cf32ed74 (patch) | |
tree | 644dfbeab1c44d239500431f350b1f8a134854df /mpz | |
parent | acfe70b0fcb2b99b526fe95bb0d677f3b13f197f (diff) | |
download | gmp-f8926b5eb5dfb44a3646b43768d92806cf32ed74.tar.gz |
* mpz/init2.c, mpz/realloc2.c: New files.
Diffstat (limited to 'mpz')
-rw-r--r-- | mpz/init2.c | 34 | ||||
-rw-r--r-- | mpz/realloc2.c | 35 |
2 files changed, 69 insertions, 0 deletions
diff --git a/mpz/init2.c b/mpz/init2.c new file mode 100644 index 000000000..f6cf114bb --- /dev/null +++ b/mpz/init2.c @@ -0,0 +1,34 @@ +/* mpz_init2 -- initialize mpz, with requested size in bits. + +Copyright 2001 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The GNU MP Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the GNU MP Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include "gmp.h" +#include "gmp-impl.h" + +void +mpz_init2 (mpz_ptr x, unsigned long bits) +{ + mp_size_t limbs; + limbs = (bits + BITS_PER_MP_LIMB-1) / BITS_PER_MP_LIMB; + limbs = MAX (limbs, 1); + SIZ(x) = 0; + ALLOC(x) = limbs; + PTR(x) = __GMP_ALLOCATE_FUNC_LIMBS (limbs); +} diff --git a/mpz/realloc2.c b/mpz/realloc2.c new file mode 100644 index 000000000..77e3a1e60 --- /dev/null +++ b/mpz/realloc2.c @@ -0,0 +1,35 @@ +/* mpz_realloc2 -- change allocated data size. + +Copyright 2001 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The GNU MP Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the GNU MP Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include "gmp.h" +#include "gmp-impl.h" + +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)); + old_limbs = ALLOC(x); + ALLOC(x) = new_limbs; + PTR(x) = __GMP_REALLOCATE_FUNC_LIMBS (PTR(x), old_limbs, new_limbs); +} |