summaryrefslogtreecommitdiffstats
path: root/libtommath/bn_mp_div_2d.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2017-09-05 12:28:41 (GMT)
committerdgp <dgp@users.sourceforge.net>2017-09-05 12:28:41 (GMT)
commit018892450cdacc7e4660a4cc138a51e1143a2b12 (patch)
treebc8d5053c422ca180b237864f9522bb64c885cf9 /libtommath/bn_mp_div_2d.c
parentd23fe52664cbef62956cc8ba4e689b9873992b0c (diff)
parentedb7af10d93df44cc25e9dce384c61669ce73dc8 (diff)
downloadtcl-tip_282.zip
tcl-tip_282.tar.gz
tcl-tip_282.tar.bz2
merge trunktip_282
Diffstat (limited to 'libtommath/bn_mp_div_2d.c')
-rw-r--r--libtommath/bn_mp_div_2d.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/libtommath/bn_mp_div_2d.c b/libtommath/bn_mp_div_2d.c
index 49d7479..d76de1a 100644
--- a/libtommath/bn_mp_div_2d.c
+++ b/libtommath/bn_mp_div_2d.c
@@ -20,8 +20,6 @@ int mp_div_2d (const mp_int * a, int b, mp_int * c, mp_int * d)
{
mp_digit D, r, rr;
int x, res;
- mp_int t;
-
/* if the shift count is <= 0 then we do no work */
if (b <= 0) {
@@ -32,24 +30,19 @@ int mp_div_2d (const mp_int * a, int b, mp_int * c, mp_int * d)
return res;
}
- if ((res = mp_init (&t)) != MP_OKAY) {
+ /* copy */
+ if ((res = mp_copy (a, c)) != MP_OKAY) {
return res;
}
+ /* 'a' should not be used after here - it might be the same as d */
/* get the remainder */
if (d != NULL) {
- if ((res = mp_mod_2d (a, b, &t)) != MP_OKAY) {
- mp_clear (&t);
+ if ((res = mp_mod_2d (a, b, d)) != MP_OKAY) {
return res;
}
}
- /* copy */
- if ((res = mp_copy (a, c)) != MP_OKAY) {
- mp_clear (&t);
- return res;
- }
-
/* shift by as many digits in the bit count */
if (b >= (int)DIGIT_BIT) {
mp_rshd (c, b / DIGIT_BIT);
@@ -84,14 +77,10 @@ int mp_div_2d (const mp_int * a, int b, mp_int * c, mp_int * d)
}
}
mp_clamp (c);
- if (d != NULL) {
- mp_exch (&t, d);
- }
- mp_clear (&t);
return MP_OKAY;
}
#endif
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */