s_mp_radix_size_overestimate: remove overflow check
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
diff --git a/mp_grow.c b/mp_grow.c
index 0de6679..344a5a8 100644
--- a/mp_grow.c
+++ b/mp_grow.c
@@ -8,6 +8,7 @@ mp_err mp_grow(mp_int *a, int size)
{
/* if the alloc size is smaller alloc more ram */
if (a->alloc < size) {
+ /* TODO */
/* reallocate the array a->dp
*
* We store the return in a temporary variable
diff --git a/mp_init_size.c b/mp_init_size.c
index 9aa98b9..fb7a37d 100644
--- a/mp_init_size.c
+++ b/mp_init_size.c
@@ -8,6 +8,7 @@ mp_err mp_init_size(mp_int *a, int size)
{
size = MP_MAX(MP_MIN_PREC, size);
+ /*TODO*/
/* alloc mem */
a->dp = (mp_digit *) MP_CALLOC((size_t)size, sizeof(mp_digit));
if (a->dp == NULL) {
diff --git a/s_mp_radix_size_overestimate.c b/s_mp_radix_size_overestimate.c
index 35dd1e6..4f05997 100644
--- a/s_mp_radix_size_overestimate.c
+++ b/s_mp_radix_size_overestimate.c
@@ -52,12 +52,7 @@ mp_err s_mp_radix_size_overestimate(const mp_int *a, const int radix, size_t *si
if (MP_HAS(S_MP_LOG_2EXPT) && MP_IS_2EXPT((mp_digit)radix)) {
/* floor(log_{2^n}(a)) + 1 + EOS + sign */
- *size = (size_t)(s_mp_log_2expt(a, (mp_digit)radix));
- /* Would overflow with base 2 otherwise */
- if (*size > (INT_MAX - 4)) {
- return MP_VAL;
- }
- *size += 3u;
+ *size = (size_t)(s_mp_log_2expt(a, (mp_digit)radix) + 3);
return MP_OKAY;
}