diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-10-02 15:22:27 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-10-02 15:22:27 (GMT) |
commit | afc317f97f0177e386ef463d2204be712252ceec (patch) | |
tree | b626ca6f62abaeff0393253fb9dbc4f0c3cfa5f5 /libtommath/bn_mp_add_d.c | |
parent | 30f7e69b182d1267056ee2628a860891f6555aa3 (diff) | |
download | tcl-afc317f97f0177e386ef463d2204be712252ceec.zip tcl-afc317f97f0177e386ef463d2204be712252ceec.tar.gz tcl-afc317f97f0177e386ef463d2204be712252ceec.tar.bz2 |
'const'ify all libtommath functions, will appear in next libtommath version. See: pull request [https://github.com/libtom/libtommath/pull/88|88]libtommath
Diffstat (limited to 'libtommath/bn_mp_add_d.c')
-rw-r--r-- | libtommath/bn_mp_add_d.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libtommath/bn_mp_add_d.c b/libtommath/bn_mp_add_d.c index 1e6ff63..e5ede1f 100644 --- a/libtommath/bn_mp_add_d.c +++ b/libtommath/bn_mp_add_d.c @@ -16,7 +16,7 @@ */ /* single digit addition */ -int mp_add_d(mp_int *a, mp_digit b, mp_int *c) +int mp_add_d(const mp_int *a, mp_digit b, mp_int *c) { int res, ix, oldused; mp_digit *tmpa, *tmpc, mu; @@ -30,14 +30,15 @@ int mp_add_d(mp_int *a, mp_digit b, mp_int *c) /* if a is negative and |a| >= b, call c = |a| - b */ if ((a->sign == MP_NEG) && ((a->used > 1) || (a->dp[0] >= b))) { + mp_int a_ = *a; /* temporarily fix sign of a */ - a->sign = MP_ZPOS; + a_.sign = MP_ZPOS; /* c = |a| - b */ - res = mp_sub_d(a, b, c); + res = mp_sub_d(&a_, b, c); /* fix sign */ - a->sign = c->sign = MP_NEG; + c->sign = MP_NEG; /* clamp */ mp_clamp(c); |