comparison libtommath/bn_mp_clear.c @ 1692:1051e4eea25a

Update LibTomMath to 1.2.0 (#84) * update C files * update other files * update headers * update makefiles * remove mp_set/get_double() * use ltm 1.2.0 API * update ltm_desc * use bundled tommath if system-tommath is too old * XMALLOC etc. were changed to MP_MALLOC etc.
author Steffen Jaeckel <s@jaeckel.eu>
date Tue, 26 May 2020 17:36:47 +0200
parents f52919ffd3b1
children
comparison
equal deleted inserted replaced
1691:2d3745d58843 1692:1051e4eea25a
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 * SPDX-License-Identifier: Unlicense
14 */
15 5
16 /* clear one (frees) */ 6 /* clear one (frees) */
17 void mp_clear(mp_int *a) 7 void mp_clear(mp_int *a)
18 { 8 {
19 /* only do anything if a hasn't been freed previously */ 9 /* only do anything if a hasn't been freed previously */
20 if (a->dp != NULL) { 10 if (a->dp != NULL) {
21 /* first zero the digits */
22 m_burn(a->dp, (size_t)a->alloc * sizeof(*a->dp));
23
24 /* free ram */ 11 /* free ram */
25 XFREE(a->dp); 12 MP_FREE_DIGITS(a->dp, a->alloc);
26 13
27 /* reset members to make debugging easier */ 14 /* reset members to make debugging easier */
28 a->dp = NULL; 15 a->dp = NULL;
29 a->alloc = a->used = 0; 16 a->alloc = a->used = 0;
30 a->sign = MP_ZPOS; 17 a->sign = MP_ZPOS;
31 } 18 }
32 } 19 }
33 #endif 20 #endif
34
35 /* ref: HEAD -> master, tag: v1.1.0 */
36 /* git commit: 08549ad6bc8b0cede0b357a9c341c5c6473a9c55 */
37 /* commit time: 2019-01-28 20:32:32 +0100 */