summaryrefslogtreecommitdiffstats
path: root/generic/tclTomMathInterface.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-11-08 09:01:43 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-11-08 09:01:43 (GMT)
commit5de9b738d3fc73ba62f781f55ba8891ccec9764a (patch)
tree2dfe8e46cde63cf66758cd794762d3c26ea99ce3 /generic/tclTomMathInterface.c
parent2325ddede0d49a1700d83457e8e36da87e548ccf (diff)
parent65946d3f86dd49b65b128b71d4b2c4b4a020a277 (diff)
downloadtcl-5de9b738d3fc73ba62f781f55ba8891ccec9764a.zip
tcl-5de9b738d3fc73ba62f781f55ba8891ccec9764a.tar.gz
tcl-5de9b738d3fc73ba62f781f55ba8891ccec9764a.tar.bz2
Merge 8.6.
Add support for libtommath's mp_set_ll() function, since that's the replacement for the deprecated TclBNInitBignumFromWideInt() function.
Diffstat (limited to 'generic/tclTomMathInterface.c')
-rw-r--r--generic/tclTomMathInterface.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/generic/tclTomMathInterface.c b/generic/tclTomMathInterface.c
index 589599e..9cb5c37 100644
--- a/generic/tclTomMathInterface.c
+++ b/generic/tclTomMathInterface.c
@@ -111,16 +111,10 @@ TclBNInitBignumFromWideInt(
mp_int *a, /* Bignum to initialize */
Tcl_WideInt v) /* Initial value */
{
- if (mp_init(a) != MP_OKAY) {
- wipanic:
- Tcl_Panic("initialization failure in TclBNInitBignumFromWideInt");
- }
- if (v < 0) {
- mp_set_ull(a, (Tcl_WideUInt)(-v));
- if (mp_neg(a, a) != MP_OKAY) goto wipanic;
- } else {
- mp_set_ull(a, (Tcl_WideUInt)v);
+ if (mp_init(a) != MP_OKAY) {
+ Tcl_Panic("insufficient memory to create bignum");
}
+ mp_set_ll(a, v);
}
/*
@@ -144,10 +138,10 @@ TclBNInitBignumFromWideUInt(
mp_int *a, /* Bignum to initialize */
Tcl_WideUInt v) /* Initial value */
{
- if (mp_init(a) != MP_OKAY) {
- Tcl_Panic("initialization failure in TclBNInitBignumFromWideUInt");
- }
- mp_set_ull(a, v);
+ if (mp_init(a) != MP_OKAY) {
+ Tcl_Panic("insufficient memory to create bignum");
+ }
+ mp_set_ull(a, v);
}
/*