summaryrefslogtreecommitdiffstats
path: root/generic/tclTomMathInterface.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-04-11 20:09:27 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-04-11 20:09:27 (GMT)
commit7df97e929223d6b0ff18cbfaad9809c18e11c3ff (patch)
tree1f7c03de38e4e36aea930f0938e49b9145e60197 /generic/tclTomMathInterface.c
parent417474f1fd64cb819d61f662390ad20a4ad66706 (diff)
downloadtcl-7df97e929223d6b0ff18cbfaad9809c18e11c3ff.zip
tcl-7df97e929223d6b0ff18cbfaad9809c18e11c3ff.tar.gz
tcl-7df97e929223d6b0ff18cbfaad9809c18e11c3ff.tar.bz2
Only use special mp_sqrt() code when double format/tommath format are exactly what's expected. Otherwise, use original always-working tommath code.
Simplify overflow check in bignum expononent code, not using bignums where it's not necessary. Don't overallocate bignums when using wideint's only.
Diffstat (limited to 'generic/tclTomMathInterface.c')
-rw-r--r--generic/tclTomMathInterface.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/generic/tclTomMathInterface.c b/generic/tclTomMathInterface.c
index d7da4ee..902fd8d 100644
--- a/generic/tclTomMathInterface.c
+++ b/generic/tclTomMathInterface.c
@@ -119,8 +119,7 @@ TclBNInitBignumFromLong(
* Allocate enough memory to hold the largest possible long
*/
- status = mp_init_size(a,
- (CHAR_BIT * sizeof(long) + DIGIT_BIT - 1) / DIGIT_BIT);
+ status = mp_init(a);
if (status != MP_OKAY) {
Tcl_Panic("initialization failure in TclBNInitBignumFromLong");
}
@@ -206,8 +205,7 @@ TclBNInitBignumFromWideUInt(
* Allocate enough memory to hold the largest possible Tcl_WideUInt.
*/
- status = mp_init_size(a,
- (CHAR_BIT * sizeof(Tcl_WideUInt) + DIGIT_BIT - 1) / DIGIT_BIT);
+ status = mp_init(a);
if (status != MP_OKAY) {
Tcl_Panic("initialization failure in TclBNInitBignumFromWideUInt");
}