summaryrefslogtreecommitdiffstats
path: root/libtommath/bn_mp_mul_2.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-09-18 08:31:55 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-09-18 08:31:55 (GMT)
commita187f65cfd5964971d7ed52f09e18fdbb4bf51cc (patch)
tree6b7bbde03122d1571d4543d10eccfe88610bd680 /libtommath/bn_mp_mul_2.c
parent0faaca01de4e9fa2039c7fdd34f60b138f665249 (diff)
parent30f7e69b182d1267056ee2628a860891f6555aa3 (diff)
downloadtcl-a187f65cfd5964971d7ed52f09e18fdbb4bf51cc.zip
tcl-a187f65cfd5964971d7ed52f09e18fdbb4bf51cc.tar.gz
tcl-a187f65cfd5964971d7ed52f09e18fdbb4bf51cc.tar.bz2
Merge libtommath upstream changes (astyle formatting only). No functional changes. All Tcl-specific modifications are kept.
Diffstat (limited to 'libtommath/bn_mp_mul_2.c')
-rw-r--r--libtommath/bn_mp_mul_2.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/libtommath/bn_mp_mul_2.c b/libtommath/bn_mp_mul_2.c
index 0c8c2e3..1744681 100644
--- a/libtommath/bn_mp_mul_2.c
+++ b/libtommath/bn_mp_mul_2.c
@@ -16,64 +16,64 @@
*/
/* b = a*2 */
-int mp_mul_2(const mp_int * a, mp_int * b)
+int mp_mul_2(const mp_int *a, mp_int *b)
{
- int x, res, oldused;
+ int x, res, oldused;
- /* grow to accomodate result */
- if (b->alloc < (a->used + 1)) {
- if ((res = mp_grow (b, a->used + 1)) != MP_OKAY) {
- return res;
- }
- }
+ /* grow to accomodate result */
+ if (b->alloc < (a->used + 1)) {
+ if ((res = mp_grow(b, a->used + 1)) != MP_OKAY) {
+ return res;
+ }
+ }
- oldused = b->used;
- b->used = a->used;
+ oldused = b->used;
+ b->used = a->used;
- {
- mp_digit r, rr, *tmpa, *tmpb;
+ {
+ mp_digit r, rr, *tmpa, *tmpb;
- /* alias for source */
- tmpa = a->dp;
-
- /* alias for dest */
- tmpb = b->dp;
+ /* alias for source */
+ tmpa = a->dp;
- /* carry */
- r = 0;
- for (x = 0; x < a->used; x++) {
-
- /* get what will be the *next* carry bit from the
- * MSB of the current digit
- */
- rr = *tmpa >> ((mp_digit)(DIGIT_BIT - 1));
-
- /* now shift up this digit, add in the carry [from the previous] */
- *tmpb++ = ((*tmpa++ << ((mp_digit)1)) | r) & MP_MASK;
-
- /* copy the carry that would be from the source
- * digit into the next iteration
- */
- r = rr;
- }
+ /* alias for dest */
+ tmpb = b->dp;
+
+ /* carry */
+ r = 0;
+ for (x = 0; x < a->used; x++) {
+
+ /* get what will be the *next* carry bit from the
+ * MSB of the current digit
+ */
+ rr = *tmpa >> ((mp_digit)(DIGIT_BIT - 1));
- /* new leading digit? */
- if (r != 0) {
- /* add a MSB which is always 1 at this point */
- *tmpb = 1;
- ++(b->used);
- }
+ /* now shift up this digit, add in the carry [from the previous] */
+ *tmpb++ = ((*tmpa++ << ((mp_digit)1)) | r) & MP_MASK;
- /* now zero any excess digits on the destination
- * that we didn't write to
- */
- tmpb = b->dp + b->used;
- for (x = b->used; x < oldused; x++) {
- *tmpb++ = 0;
- }
- }
- b->sign = a->sign;
- return MP_OKAY;
+ /* copy the carry that would be from the source
+ * digit into the next iteration
+ */
+ r = rr;
+ }
+
+ /* new leading digit? */
+ if (r != 0) {
+ /* add a MSB which is always 1 at this point */
+ *tmpb = 1;
+ ++(b->used);
+ }
+
+ /* now zero any excess digits on the destination
+ * that we didn't write to
+ */
+ tmpb = b->dp + b->used;
+ for (x = b->used; x < oldused; x++) {
+ *tmpb++ = 0;
+ }
+ }
+ b->sign = a->sign;
+ return MP_OKAY;
}
#endif