Bump actions/upload-artifacts version
[libtommath.git] / mp_init.c
blobaf1674481ca9930cc2affddb60a6fa4f15abc95b
1 #include "tommath_private.h"
2 #ifdef MP_INIT_C
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */
4 /* SPDX-License-Identifier: Unlicense */
6 /* init a new mp_int */
7 mp_err mp_init(mp_int *a)
9 /* allocate memory required and clear it */
10 a->dp = (mp_digit *) MP_CALLOC((size_t)MP_DEFAULT_DIGIT_COUNT, sizeof(mp_digit));
11 if (a->dp == NULL) {
12 return MP_MEM;
15 /* set the used to zero, allocated digits to the default precision
16 * and sign to positive */
17 a->used = 0;
18 a->alloc = MP_DEFAULT_DIGIT_COUNT;
19 a->sign = MP_ZPOS;
21 return MP_OKAY;
23 #endif