libtommath/s_mp_reverse.c

23 lines
445 B
C
Raw Normal View History

#include "tommath_private.h"
#ifdef S_MP_REVERSE_C
2019-04-07 13:29:11 +00:00
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
2003-02-28 16:08:34 +00:00
/* reverse an array, used for radix code */
void s_mp_reverse(unsigned char *s, size_t len)
2003-02-28 16:08:34 +00:00
{
size_t ix, iy;
2017-08-30 17:15:27 +00:00
unsigned char t;
2003-02-28 16:08:34 +00:00
2019-10-06 14:13:44 +00:00
ix = 0u;
iy = len - 1u;
2017-08-30 17:15:27 +00:00
while (ix < iy) {
t = s[ix];
s[ix] = s[iy];
s[iy] = t;
++ix;
--iy;
}
2003-02-28 16:08:34 +00:00
}
2004-10-29 22:07:18 +00:00
#endif