LCOV - code coverage report
Current view: top level - third_party/heimdal/lib/hcrypto/libtommath - bn_mp_fwrite.c (source / functions) Hit Total Coverage
Test: coverage report for v4-17-test 1498b464 Lines: 0 15 0.0 %
Date: 2024-06-13 04:01:37 Functions: 0 1 0.0 %

          Line data    Source code
       1             : #include "tommath_private.h"
       2             : #ifdef BN_MP_FWRITE_C
       3             : /* LibTomMath, multiple-precision integer library -- Tom St Denis */
       4             : /* SPDX-License-Identifier: Unlicense */
       5             : 
       6             : #ifndef MP_NO_FILE
       7           0 : mp_err mp_fwrite(const mp_int *a, int radix, FILE *stream)
       8             : {
       9             :    char *buf;
      10             :    mp_err err;
      11             :    int len;
      12             :    size_t written;
      13             : 
      14             :    /* TODO: this function is not in this PR */
      15             :    if (MP_HAS(MP_RADIX_SIZE_OVERESTIMATE)) {
      16             :       /* if ((err = mp_radix_size_overestimate(&t, base, &len)) != MP_OKAY)      goto LBL_ERR; */
      17             :    } else {
      18           0 :       if ((err = mp_radix_size(a, radix, &len)) != MP_OKAY) {
      19           0 :          return err;
      20             :       }
      21             :    }
      22             : 
      23           0 :    buf = (char *) MP_MALLOC((size_t)len);
      24           0 :    if (buf == NULL) {
      25           0 :       return MP_MEM;
      26             :    }
      27             : 
      28           0 :    if ((err = mp_to_radix(a, buf, (size_t)len, &written, radix)) != MP_OKAY) {
      29           0 :       goto LBL_ERR;
      30             :    }
      31             : 
      32           0 :    if (fwrite(buf, written, 1uL, stream) != 1uL) {
      33           0 :       err = MP_ERR;
      34           0 :       goto LBL_ERR;
      35             :    }
      36           0 :    err = MP_OKAY;
      37             : 
      38             : 
      39           0 : LBL_ERR:
      40           0 :    MP_FREE_BUFFER(buf, (size_t)len);
      41           0 :    return err;
      42             : }
      43             : #endif
      44             : 
      45             : #endif

Generated by: LCOV version 1.13