summaryrefslogtreecommitdiff
path: root/mpz/realloc2.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2001-11-24 01:36:18 +0100
committerKevin Ryde <user42@zip.com.au>2001-11-24 01:36:18 +0100
commitf8926b5eb5dfb44a3646b43768d92806cf32ed74 (patch)
tree644dfbeab1c44d239500431f350b1f8a134854df /mpz/realloc2.c
parentacfe70b0fcb2b99b526fe95bb0d677f3b13f197f (diff)
downloadgmp-f8926b5eb5dfb44a3646b43768d92806cf32ed74.tar.gz
* mpz/init2.c, mpz/realloc2.c: New files.
Diffstat (limited to 'mpz/realloc2.c')
-rw-r--r--mpz/realloc2.c35
1 files changed, 35 insertions, 0 deletions
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);
+}