1 #include "tommath_private.h" 2 #ifdef BN_MP_INIT_SIZE_C 3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */ 4 /* SPDX-License-Identifier: Unlicense */ 5 6 /* init an mp_init for a given size */ mp_init_size(mp_int * a,int size)7mp_err mp_init_size(mp_int *a, int size) 8 { 9 size = MP_MAX(MP_MIN_PREC, size); 10 11 /* alloc mem */ 12 a->dp = (mp_digit *) MP_CALLOC((size_t)size, sizeof(mp_digit)); 13 if (a->dp == NULL) { 14 return MP_MEM; 15 } 16 17 /* set the members */ 18 a->used = 0; 19 a->alloc = size; 20 a->sign = MP_ZPOS; 21 22 return MP_OKAY; 23 } 24 #endif 25