1 #include "tommath_private.h"
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */
4 /* SPDX-License-Identifier: Unlicense */
7 mp_err
mp_fwrite(const mp_int
*a
, int radix
, FILE *stream
)
13 if ((err
= mp_radix_size_overestimate(a
, radix
, &size
)) != MP_OKAY
) {
17 buf
= (char *) MP_MALLOC(size
);
22 if ((err
= mp_to_radix(a
, buf
, size
, &written
, radix
)) == MP_OKAY
) {
24 if (fwrite(buf
, written
, 1uL, stream
) != 1uL) {
29 MP_FREE_BUF(buf
, size
);