Skip to content

Commit 20dcc92

Browse files
committed
rename internal constant radix arrays
1 parent 55acc6a commit 20dcc92

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

bn_mp_fread.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ mp_err mp_fread(mp_int *a, int radix, FILE *stream)
3030
do {
3131
int y;
3232
unsigned pos = (unsigned)(ch - (int)'(');
33-
if (mp_s_rmap_reverse_sz < pos) {
33+
if (MP_RMAP_REVERSE_SIZE < pos) {
3434
break;
3535
}
3636

37-
y = (int)mp_s_rmap_reverse[pos];
37+
y = (int)s_mp_rmap_reverse[pos];
3838

3939
if ((y == 0xff) || (y >= radix)) {
4040
break;

bn_mp_radix_smap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
/* SPDX-License-Identifier: Unlicense */
55

66
/* chars used in radix conversions */
7-
const char *const mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
8-
const uint8_t mp_s_rmap_reverse[] = {
7+
const char s_mp_rmap[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
8+
const uint8_t s_mp_rmap_reverse[] = {
99
0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f, /* ()*+,-./ */
1010
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 01234567 */
1111
0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 89:;<=>? */
@@ -18,5 +18,5 @@ const uint8_t mp_s_rmap_reverse[] = {
1818
0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, /* pqrstuvw */
1919
0x3b, 0x3c, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, /* xyz{|}~. */
2020
};
21-
const size_t mp_s_rmap_reverse_sz = sizeof(mp_s_rmap_reverse);
21+
MP_STATIC_ASSERT(correct_rmap_reverse_size, sizeof(s_mp_rmap_reverse) == MP_RMAP_REVERSE_SIZE)
2222
#endif

bn_mp_read_radix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ mp_err mp_read_radix(mp_int *a, const char *str, int radix)
4343
*/
4444
ch = (radix <= 36) ? (char)MP_TOUPPER((int)*str) : *str;
4545
pos = (unsigned)(ch - '(');
46-
if (mp_s_rmap_reverse_sz < pos) {
46+
if (MP_RMAP_REVERSE_SIZE < pos) {
4747
break;
4848
}
49-
y = (int)mp_s_rmap_reverse[pos];
49+
y = (int)s_mp_rmap_reverse[pos];
5050

5151
/* if the char was found in the map
5252
* and is less than the given radix add it

bn_mp_to_radix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ mp_err mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, i
6060
if ((err = mp_div_d(&t, (mp_digit)radix, &t, &d)) != MP_OKAY) {
6161
goto LBL_ERR;
6262
}
63-
*str++ = mp_s_rmap[d];
63+
*str++ = s_mp_rmap[d];
6464
++digs;
6565
}
6666
/* reverse the digits of the string. In this case _s points

tommath_private.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ MP_PRIVATE mp_err s_mp_prime_is_divisible(const mp_int *a, mp_bool *result);
215215
MP_PRIVATE mp_err s_mp_rand_jenkins(void *p, size_t n) MP_WUR;
216216
MP_PRIVATE void s_mp_rand_jenkins_init(uint64_t seed);
217217

218-
extern MP_PRIVATE const char *const mp_s_rmap;
219-
extern MP_PRIVATE const uint8_t mp_s_rmap_reverse[];
220-
extern MP_PRIVATE const size_t mp_s_rmap_reverse_sz;
218+
#define MP_RMAP_REVERSE_SIZE 88
219+
extern MP_PRIVATE const char s_mp_rmap[];
220+
extern MP_PRIVATE const uint8_t s_mp_rmap_reverse[];
221221
extern MP_PRIVATE const mp_digit s_mp_prime_tab[];
222222

223223
/* number of primes */

0 commit comments

Comments
 (0)