1 #include "tommath_private.h"
2 #ifdef BN_MP_CLEAR_C
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis
4  *
5  * LibTomMath is a library that provides multiple-precision
6  * integer arithmetic as well as number theoretic functionality.
7  *
8  * The library was designed directly after the MPI library by
9  * Michael Fromberger but has been written from scratch with
10  * additional optimizations in place.
11  *
12  * SPDX-License-Identifier: Unlicense
13  */
14 
15 /* clear one (frees)  */
mp_clear(mp_int * a)16 void mp_clear(mp_int *a)
17 {
18    int i;
19 
20    /* only do anything if a hasn't been freed previously */
21    if (a->dp != NULL) {
22       /* first zero the digits */
23       for (i = 0; i < a->used; i++) {
24          a->dp[i] = 0;
25       }
26 
27       /* free ram */
28       XFREE(a->dp);
29 
30       /* reset members to make debugging easier */
31       a->dp    = NULL;
32       a->alloc = a->used = 0;
33       a->sign  = MP_ZPOS;
34    }
35 }
36 #endif
37 
38 /* ref:         $Format:%D$ */
39 /* git commit:  $Format:%H$ */
40 /* commit time: $Format:%ai$ */
41