comparison libtommath/bn_mp_clear.c @ 1739:13d834efc376 fuzz

merge from main
author Matt Johnston <matt@ucc.asn.au>
date Thu, 15 Oct 2020 19:55:15 +0800
parents 1051e4eea25a
children
comparison
equal deleted inserted replaced
1562:768ebf737aa0 1739:13d834efc376
1 #include <tommath_private.h> 1 #include "tommath_private.h"
2 #include "dbhelpers.h"
3 #ifdef BN_MP_CLEAR_C 2 #ifdef BN_MP_CLEAR_C
4 /* LibTomMath, multiple-precision integer library -- Tom St Denis 3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */
5 * 4 /* SPDX-License-Identifier: Unlicense */
6 * LibTomMath is a library that provides multiple-precision
7 * integer arithmetic as well as number theoretic functionality.
8 *
9 * The library was designed directly after the MPI library by
10 * Michael Fromberger but has been written from scratch with
11 * additional optimizations in place.
12 *
13 * The library is free for all purposes without any express
14 * guarantee it works.
15 *
16 * Tom St Denis, [email protected], http://libtom.org
17 */
18 5
19 /* clear one (frees) */ 6 /* clear one (frees) */
20 void 7 void mp_clear(mp_int *a)
21 mp_clear (mp_int * a)
22 { 8 {
23 /* only do anything if a hasn't been freed previously */ 9 /* only do anything if a hasn't been freed previously */
24 if (a->dp != NULL) { 10 if (a->dp != NULL) {
25 /* first zero the digits */ 11 /* free ram */
26 m_burn(a->dp, a->alloc * sizeof(*a->dp)); 12 MP_FREE_DIGITS(a->dp, a->alloc);
27 13
28 /* free ram */ 14 /* reset members to make debugging easier */
29 XFREE(a->dp); 15 a->dp = NULL;
30 16 a->alloc = a->used = 0;
31 /* reset members to make debugging easier */ 17 a->sign = MP_ZPOS;
32 a->dp = NULL; 18 }
33 a->alloc = a->used = 0;
34 a->sign = MP_ZPOS;
35 }
36 } 19 }
37 #endif 20 #endif
38
39 /* ref: $Format:%D$ */
40 /* git commit: $Format:%H$ */
41 /* commit time: $Format:%ai$ */