libtommath/mp_shrink.c
Steffen Jaeckel 7a68f12873 Execute move.sh - Rename files from bn_* to match the function names.
* git blame <renamed-file> is not affected
* git log --follow <renamed-file> can be used to show log across renames
2019-10-19 16:24:39 +02:00

23 lines
626 B
C

#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)
{
mp_digit *tmp;
int alloc = MP_MAX(MP_MIN_PREC, a->used);
if (a->alloc != alloc) {
if ((tmp = (mp_digit *) MP_REALLOC(a->dp,
(size_t)a->alloc * sizeof(mp_digit),
(size_t)alloc * sizeof(mp_digit))) == NULL) {
return MP_MEM;
}
a->dp = tmp;
a->alloc = alloc;
}
return MP_OKAY;
}
#endif