bn_mp_clear.c 502 B

1234567891011121314151617181920
  1. #include "tommath_private.h"
  2. #ifdef BN_MP_CLEAR_C
  3. /* LibTomMath, multiple-precision integer library -- Tom St Denis */
  4. /* SPDX-License-Identifier: Unlicense */
  5. /* clear one (frees) */
  6. void mp_clear(mp_int *a)
  7. {
  8. /* only do anything if a hasn't been freed previously */
  9. if (a->dp != NULL) {
  10. /* free ram */
  11. MP_FREE_DIGITS(a->dp, a->alloc);
  12. /* reset members to make debugging easier */
  13. a->dp = NULL;
  14. a->alloc = a->used = 0;
  15. a->sign = MP_ZPOS;
  16. }
  17. }
  18. #endif