795cd2013f
Originally I made those as macros. However we have many other small functions like mp_clamp, mp_exch which are also not implemented as macros right now. If we would use c99, I would implement them as private static inline functions. And mp_exch would be a public static inline function. But since we are bound to c89, we simply use normal functions. To achieve optimal performance one should either use link time optimization or amalgamation.
24 lines
434 B
C
24 lines
434 B
C
#include "tommath_private.h"
|
|
#ifdef S_MP_ZERO_DIGS_C
|
|
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
|
|
/* SPDX-License-Identifier: Unlicense */
|
|
|
|
#ifdef MP_USE_MEMOPS
|
|
# include <string.h>
|
|
#endif
|
|
|
|
void s_mp_zero_digs(mp_digit *d, int digits)
|
|
{
|
|
#ifdef MP_USE_MEMOPS
|
|
if (digits > 0) {
|
|
memset(d, 0, (size_t)digits * sizeof(mp_digit));
|
|
}
|
|
#else
|
|
while (digits-- > 0) {
|
|
*d++ = 0;
|
|
}
|
|
#endif
|
|
}
|
|
|
|
#endif
|