diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2012-02-23 21:17:47 +0100 |
---|---|---|
committer | Marc Glisse <marc.glisse@inria.fr> | 2012-02-23 21:17:47 +0100 |
commit | 2b06ef413348321424141880c23fea600940e25b (patch) | |
tree | d2f66feff6187bda4f7440776914199d7eb0d5b1 /mpz/sqrt.c | |
parent | 8e1827335d45a049e434a2b095558f14dd4bf36f (diff) | |
download | gmp-2b06ef413348321424141880c23fea600940e25b.tar.gz |
Use the macros ALLOC etc to access the fields of mpz_t in mpz/*.
Test mpz_abs when it requires a reallocation.
Diffstat (limited to 'mpz/sqrt.c')
-rw-r--r-- | mpz/sqrt.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/mpz/sqrt.c b/mpz/sqrt.c index a87ae75b8..91cd7051a 100644 --- a/mpz/sqrt.c +++ b/mpz/sqrt.c @@ -32,7 +32,7 @@ mpz_sqrt (mpz_ptr root, mpz_srcptr op) TMP_DECL; TMP_MARK; - op_size = op->_mp_size; + op_size = SIZ (op); if (op_size <= 0) { if (op_size < 0) @@ -44,22 +44,22 @@ mpz_sqrt (mpz_ptr root, mpz_srcptr op) /* The size of the root is accurate after this simple calculation. */ root_size = (op_size + 1) / 2; - root_ptr = root->_mp_d; - op_ptr = op->_mp_d; + root_ptr = PTR (root); + op_ptr = PTR (op); - if (root->_mp_alloc < root_size) + if (ALLOC (root) < root_size) { if (root_ptr == op_ptr) { free_me = root_ptr; - free_me_size = root->_mp_alloc; + free_me_size = ALLOC (root); } else - (*__gmp_free_func) (root_ptr, root->_mp_alloc * BYTES_PER_MP_LIMB); + (*__gmp_free_func) (root_ptr, ALLOC (root) * BYTES_PER_MP_LIMB); - root->_mp_alloc = root_size; + ALLOC (root) = root_size; root_ptr = (mp_ptr) (*__gmp_allocate_func) (root_size * BYTES_PER_MP_LIMB); - root->_mp_d = root_ptr; + PTR (root) = root_ptr; } else { @@ -76,7 +76,7 @@ mpz_sqrt (mpz_ptr root, mpz_srcptr op) mpn_sqrtrem (root_ptr, NULL, op_ptr, op_size); - root->_mp_size = root_size; + SIZ (root) = root_size; if (free_me != NULL) (*__gmp_free_func) (free_me, free_me_size * BYTES_PER_MP_LIMB); |