summaryrefslogtreecommitdiff
path: root/Build/source/libs/gmp/gmp-src/mpn/generic/divrem.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/gmp/gmp-src/mpn/generic/divrem.c')
-rw-r--r--Build/source/libs/gmp/gmp-src/mpn/generic/divrem.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/Build/source/libs/gmp/gmp-src/mpn/generic/divrem.c b/Build/source/libs/gmp/gmp-src/mpn/generic/divrem.c
index f420992746e..1da84a8e1ac 100644
--- a/Build/source/libs/gmp/gmp-src/mpn/generic/divrem.c
+++ b/Build/source/libs/gmp/gmp-src/mpn/generic/divrem.c
@@ -1,7 +1,7 @@
/* mpn_divrem -- Divide natural numbers, producing both remainder and
quotient. This is now just a middle layer calling mpn_tdiv_qr.
-Copyright 1993-1997, 1999-2002, 2005 Free Software Foundation, Inc.
+Copyright 1993-1997, 1999-2002, 2005, 2016 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -29,7 +29,6 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
-#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h"
@@ -72,7 +71,7 @@ mpn_divrem (mp_ptr qp, mp_size_t qxn,
}
else
{
- mp_ptr rp, q2p;
+ mp_ptr q2p;
mp_limb_t qhl;
mp_size_t qn;
TMP_DECL;
@@ -81,13 +80,11 @@ mpn_divrem (mp_ptr qp, mp_size_t qxn,
if (UNLIKELY (qxn != 0))
{
mp_ptr n2p;
- n2p = TMP_ALLOC_LIMBS (nn + qxn);
+ TMP_ALLOC_LIMBS_2 (n2p, nn + qxn,
+ q2p, nn - dn + qxn + 1);
MPN_ZERO (n2p, qxn);
MPN_COPY (n2p + qxn, np, nn);
- q2p = TMP_ALLOC_LIMBS (nn - dn + qxn + 1);
- rp = TMP_ALLOC_LIMBS (dn);
- mpn_tdiv_qr (q2p, rp, 0L, n2p, nn + qxn, dp, dn);
- MPN_COPY (np, rp, dn);
+ mpn_tdiv_qr (q2p, np, 0L, n2p, nn + qxn, dp, dn);
qn = nn - dn + qxn;
MPN_COPY (qp, q2p, qn);
qhl = q2p[qn];
@@ -95,9 +92,7 @@ mpn_divrem (mp_ptr qp, mp_size_t qxn,
else
{
q2p = TMP_ALLOC_LIMBS (nn - dn + 1);
- rp = TMP_ALLOC_LIMBS (dn);
- mpn_tdiv_qr (q2p, rp, 0L, np, nn, dp, dn);
- MPN_COPY (np, rp, dn); /* overwrite np area with remainder */
+ mpn_tdiv_qr (q2p, np, 0L, np, nn, dp, dn);
qn = nn - dn;
MPN_COPY (qp, q2p, qn);
qhl = q2p[qn];