Skip to content

Commit 12af2b3

Browse files
committed
Statically allocate where possible
1 parent ae82705 commit 12af2b3

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

bn_mp_todecimal_fast.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ mp_err mp_todecimal_fast_rec(mp_int *number, mp_int *nL, mp_int *shiftL, mp_int
7373
mp_err mp_todecimal_fast(mp_int *number, char **result)
7474
{
7575
mp_int n, shift, M, M2, M22, M4, M44;
76-
mp_int *nL, *shiftL, *mL;
76+
mp_int nL[20], shiftL[20], mL[20];
7777
mp_err err;
7878
int precalc_array_index = 1;
7979

@@ -91,7 +91,6 @@ mp_err mp_todecimal_fast(mp_int *number, char **result)
9191
goto LBL_ERR;
9292
}
9393

94-
nL = malloc(20 * sizeof(mp_int));
9594
if ((err = mp_init_copy(&nL[0], &n)) != MP_OKAY) {
9695
goto LBL_ERR;
9796
}
@@ -100,7 +99,6 @@ mp_err mp_todecimal_fast(mp_int *number, char **result)
10099
goto LBL_ERR;
101100
}
102101

103-
shiftL = malloc(20 * sizeof(mp_int));
104102
if ((err = mp_init_copy(&shiftL[0], &shift)) != MP_OKAY) {
105103
goto LBL_ERR;
106104
}
@@ -111,7 +109,6 @@ mp_err mp_todecimal_fast(mp_int *number, char **result)
111109
}
112110

113111
/* $M / 8, rounded up */
114-
mL = malloc(20 * sizeof(mp_int));
115112
if ((err = mp_init_set(&mL[0], (mp_digit)1049)) != MP_OKAY) {
116113
goto LBL_ERR;
117114
}

0 commit comments

Comments
 (0)