Change the compiler's big integer library to use libTomMath

This now replaces Bill's crappy big int implementation
This commit is contained in:
gingerBill
2021-07-11 16:08:16 +01:00
parent ebcabb8a27
commit 460e14e586
171 changed files with 10745 additions and 1155 deletions
+22
View File
@@ -0,0 +1,22 @@
#include "tommath_private.h"
#ifdef MP_SHRINK_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
/* shrink a bignum */
mp_err mp_shrink(mp_int *a)
{
int alloc = MP_MAX(MP_MIN_DIGIT_COUNT, a->used);
if (a->alloc != alloc) {
mp_digit *dp = (mp_digit *) MP_REALLOC(a->dp,
(size_t)a->alloc * sizeof(mp_digit),
(size_t)alloc * sizeof(mp_digit));
if (dp == NULL) {
return MP_MEM;
}
a->dp = dp;
a->alloc = alloc;
}
return MP_OKAY;
}
#endif