File tree Expand file tree Collapse file tree 2 files changed +2
-16
lines changed Expand file tree Collapse file tree 2 files changed +2
-16
lines changed Original file line number Diff line number Diff line change 1515/* init a new mp_int */
1616int mp_init (mp_int * a )
1717{
18- int i ;
19-
2018 /* allocate memory required and clear it */
21- a -> dp = (mp_digit * ) XMALLOC ( MP_PREC * sizeof (mp_digit ));
19+ a -> dp = (mp_digit * ) XCALLOC (( size_t ) MP_PREC , sizeof (mp_digit ));
2220 if (a -> dp == NULL ) {
2321 return MP_MEM ;
2422 }
2523
26- /* set the digits to zero */
27- for (i = 0 ; i < MP_PREC ; i ++ ) {
28- a -> dp [i ] = 0 ;
29- }
30-
3124 /* set the used to zero, allocated digits to the default precision
3225 * and sign to positive */
3326 a -> used = 0 ;
Original file line number Diff line number Diff line change 1515/* init an mp_init for a given size */
1616int mp_init_size (mp_int * a , int size )
1717{
18- int x ;
19-
2018 /* pad size so there are always extra digits */
2119 size += (MP_PREC * 2 ) - (size % MP_PREC );
2220
2321 /* alloc mem */
24- a -> dp = (mp_digit * ) XMALLOC ((size_t )size * sizeof (mp_digit ));
22+ a -> dp = (mp_digit * ) XCALLOC ((size_t )size , sizeof (mp_digit ));
2523 if (a -> dp == NULL ) {
2624 return MP_MEM ;
2725 }
@@ -31,11 +29,6 @@ int mp_init_size(mp_int *a, int size)
3129 a -> alloc = size ;
3230 a -> sign = MP_ZPOS ;
3331
34- /* zero the digits */
35- for (x = 0 ; x < size ; x ++ ) {
36- a -> dp [x ] = 0 ;
37- }
38-
3932 return MP_OKAY ;
4033}
4134#endif
You can’t perform that action at this time.
0 commit comments