diff options
author | Torbjorn Granlund <torbjorng@google.com> | 2015-09-29 21:24:58 +0200 |
---|---|---|
committer | Torbjorn Granlund <torbjorng@google.com> | 2015-09-29 21:24:58 +0200 |
commit | 25ff0b07e50cae0ff51b9e4fa96d4a2e70e3d910 (patch) | |
tree | 073f3464080d68a1c6ef967462d50f746c2bf3fd | |
parent | 99daa66cdd004e0390ba631a4c3de736fbfd18a9 (diff) | |
download | gmp-25ff0b07e50cae0ff51b9e4fa96d4a2e70e3d910.tar.gz |
Streamline, use macros.
-rw-r--r-- | mpf/clear.c | 4 | ||||
-rw-r--r-- | mpf/clears.c | 9 | ||||
-rw-r--r-- | mpf/inits.c | 7 | ||||
-rw-r--r-- | mpq/clear.c | 10 | ||||
-rw-r--r-- | mpq/clears.c | 13 | ||||
-rw-r--r-- | mpq/inits.c | 7 | ||||
-rw-r--r-- | mpz/clear.c | 8 | ||||
-rw-r--r-- | mpz/clears.c | 9 | ||||
-rw-r--r-- | mpz/inits.c | 17 |
9 files changed, 47 insertions, 37 deletions
diff --git a/mpf/clear.c b/mpf/clear.c index 2df0de579..9ff2dd336 100644 --- a/mpf/clear.c +++ b/mpf/clear.c @@ -33,7 +33,7 @@ see https://www.gnu.org/licenses/. */ #include "gmp-impl.h" void -mpf_clear (mpf_ptr m) +mpf_clear (mpf_ptr x) { - (*__gmp_free_func) (m->_mp_d, (size_t) (m->_mp_prec + 1) * GMP_LIMB_BYTES); + __GMP_FREE_FUNC_LIMBS (PTR(x), PREC(x) + 1); } diff --git a/mpf/clears.c b/mpf/clears.c index addbe8faf..17eca8208 100644 --- a/mpf/clears.c +++ b/mpf/clears.c @@ -1,6 +1,6 @@ /* mpf_clears() -- Clear multiple mpf_t variables. -Copyright 2009, 2014 Free Software Foundation, Inc. +Copyright 2009, 2014, 2015 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -29,7 +29,6 @@ GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include <stdarg.h> -#include <stdio.h> /* for NULL */ #include "gmp.h" #include "gmp-impl.h" @@ -40,10 +39,12 @@ mpf_clears (mpf_ptr x, ...) va_start (ap, x); - while (x != NULL) + do { - (*__gmp_free_func) (x->_mp_d, (size_t) (x->_mp_prec + 1) * GMP_LIMB_BYTES); + __GMP_FREE_FUNC_LIMBS (PTR(x), PREC(x) + 1); x = va_arg (ap, mpf_ptr); } + while (x != NULL); + va_end (ap); } diff --git a/mpf/inits.c b/mpf/inits.c index fb14c6b0f..ddcf1141a 100644 --- a/mpf/inits.c +++ b/mpf/inits.c @@ -1,6 +1,6 @@ /* mpf_inits() -- Initialize multiple mpf_t variables and set them to 0. -Copyright 2009 Free Software Foundation, Inc. +Copyright 2009, 2015 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -29,7 +29,6 @@ GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include <stdarg.h> -#include <stdio.h> /* for NULL */ #include "gmp.h" #include "gmp-impl.h" @@ -40,10 +39,12 @@ mpf_inits (mpf_ptr x, ...) va_start (ap, x); - while (x != NULL) + do { mpf_init (x); x = va_arg (ap, mpf_ptr); } + while (x != NULL); + va_end (ap); } diff --git a/mpq/clear.c b/mpq/clear.c index 6de593f8b..9b08f239c 100644 --- a/mpq/clear.c +++ b/mpq/clear.c @@ -1,6 +1,6 @@ /* mpq_clear -- free the space occupied by an mpq_t. -Copyright 1991, 1994, 1995, 2000, 2001 Free Software Foundation, Inc. +Copyright 1991, 1994, 1995, 2000, 2001, 2015 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -32,10 +32,8 @@ see https://www.gnu.org/licenses/. */ #include "gmp-impl.h" void -mpq_clear (mpq_t m) +mpq_clear (mpq_t x) { - (*__gmp_free_func) (PTR(NUM(m)), - (size_t) ALLOC(NUM(m)) * GMP_LIMB_BYTES); - (*__gmp_free_func) (PTR(DEN(m)), - (size_t) ALLOC(DEN(m)) * GMP_LIMB_BYTES); + __GMP_FREE_FUNC_LIMBS (PTR(NUM(x)), ALLOC(NUM(x))); + __GMP_FREE_FUNC_LIMBS (PTR(DEN(x)), ALLOC(DEN(x))); } diff --git a/mpq/clears.c b/mpq/clears.c index f949fe36c..c5f6539a6 100644 --- a/mpq/clears.c +++ b/mpq/clears.c @@ -1,6 +1,6 @@ /* mpq_clears() -- Clear multiple mpq_t variables. -Copyright 2009, 2014 Free Software Foundation, Inc. +Copyright 2009, 2014, 2015 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -29,7 +29,6 @@ GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include <stdarg.h> -#include <stdio.h> /* for NULL */ #include "gmp.h" #include "gmp-impl.h" @@ -40,13 +39,13 @@ mpq_clears (mpq_ptr x, ...) va_start (ap, x); - while (x != NULL) + do { - (*__gmp_free_func) (PTR(NUM(x)), - (size_t) ALLOC(NUM(x)) * GMP_LIMB_BYTES); - (*__gmp_free_func) (PTR(DEN(x)), - (size_t) ALLOC(DEN(x)) * GMP_LIMB_BYTES); + __GMP_FREE_FUNC_LIMBS (PTR(NUM(x)), ALLOC(NUM(x))); + __GMP_FREE_FUNC_LIMBS (PTR(DEN(x)), ALLOC(DEN(x))); x = va_arg (ap, mpq_ptr); } + while (x != NULL); + va_end (ap); } diff --git a/mpq/inits.c b/mpq/inits.c index 97c41656f..084c71e00 100644 --- a/mpq/inits.c +++ b/mpq/inits.c @@ -1,6 +1,6 @@ /* mpq_inits() -- Initialize multiple mpq_t variables and set them to 0. -Copyright 2009 Free Software Foundation, Inc. +Copyright 2009, 2015 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -29,7 +29,6 @@ GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include <stdarg.h> -#include <stdio.h> /* for NULL */ #include "gmp.h" #include "gmp-impl.h" @@ -40,10 +39,12 @@ mpq_inits (mpq_ptr x, ...) va_start (ap, x); - while (x != NULL) + do { mpq_init (x); x = va_arg (ap, mpq_ptr); } + while (x != NULL); + va_end (ap); } diff --git a/mpz/clear.c b/mpz/clear.c index 30f626c50..d1541e91c 100644 --- a/mpz/clear.c +++ b/mpz/clear.c @@ -1,8 +1,8 @@ /* mpz_clear -- de-allocate the space occupied by the dynamic digit space of an integer. -Copyright 1991, 1993-1995, 2000, 2001, 2012, 2014 Free Software Foundation, -Inc. +Copyright 1991, 1993-1995, 2000, 2001, 2012, 2014, 2015 Free Software +Foundation, Inc. This file is part of the GNU MP Library. @@ -34,7 +34,7 @@ see https://www.gnu.org/licenses/. */ #include "gmp-impl.h" void -mpz_clear (mpz_ptr m) +mpz_clear (mpz_ptr x) { - (*__gmp_free_func) (PTR (m), (size_t) ALLOC (m) * GMP_LIMB_BYTES); + __GMP_FREE_FUNC_LIMBS (PTR (x), ALLOC(x)); } diff --git a/mpz/clears.c b/mpz/clears.c index 193c5ade7..27c3bb345 100644 --- a/mpz/clears.c +++ b/mpz/clears.c @@ -1,6 +1,6 @@ /* mpz_clears() -- Clear multiple mpz_t variables. -Copyright 2009, 2014 Free Software Foundation, Inc. +Copyright 2009, 2014, 2015 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -29,7 +29,6 @@ GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include <stdarg.h> -#include <stdio.h> /* for NULL */ #include "gmp.h" #include "gmp-impl.h" @@ -40,10 +39,12 @@ mpz_clears (mpz_ptr x, ...) va_start (ap, x); - while (x != NULL) + do { - (*__gmp_free_func) (PTR (x), (size_t) ALLOC (x) * GMP_LIMB_BYTES); + __GMP_FREE_FUNC_LIMBS (PTR (x), ALLOC(x)); x = va_arg (ap, mpz_ptr); } + while (x != NULL); + va_end (ap); } diff --git a/mpz/inits.c b/mpz/inits.c index 0488edaa4..7d13883e1 100644 --- a/mpz/inits.c +++ b/mpz/inits.c @@ -1,6 +1,6 @@ /* mpz_inits() -- Initialize multiple mpz_t variables and set them to 0. -Copyright 2009 Free Software Foundation, Inc. +Copyright 2009, 2015 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -29,7 +29,6 @@ GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include <stdarg.h> -#include <stdio.h> /* for NULL */ #include "gmp.h" #include "gmp-impl.h" @@ -40,10 +39,20 @@ mpz_inits (mpz_ptr x, ...) va_start (ap, x); - while (x != NULL) + do { - mpz_init (x); + ALLOC (x) = 1; + PTR (x) = __GMP_ALLOCATE_FUNC_LIMBS (1); + SIZ (x) = 0; + +#ifdef __CHECKER__ + /* let the low limb look initialized, for the benefit of mpz_get_ui etc */ + PTR (x) = 0; +#endif + x = va_arg (ap, mpz_ptr); } + while (x != NULL); + va_end (ap); } |