comparison bn_mp_clear.c @ 200:c5c969ed76f3 libtommath

propagate from branch 'au.asn.ucc.matt.ltm-orig' (head 7fa10cba9535de3461cedb14b877c24858826204) to branch 'au.asn.ucc.matt.dropbear.ltm' (head fc26f60de0370ab0a281fa41a2d13fb17c9d90a8)
author Matt Johnston <matt@ucc.asn.au>
date Wed, 11 May 2005 16:15:27 +0000
parents 8e94663164c6
children
comparison
equal deleted inserted replaced
190:d8254fc979e9 200:c5c969ed76f3
17 17
18 /* clear one (frees) */ 18 /* clear one (frees) */
19 void 19 void
20 mp_clear (mp_int * a) 20 mp_clear (mp_int * a)
21 { 21 {
22 int i; 22 volatile mp_digit *p;
23 int len;
23 24
24 /* only do anything if a hasn't been freed previously */ 25 /* only do anything if a hasn't been freed previously */
25 if (a->dp != NULL) { 26 if (a->dp != NULL) {
26 /* first zero the digits */ 27 /* first zero the digits */
27 for (i = 0; i < a->used; i++) { 28 len = a->alloc;
28 a->dp[i] = 0; 29 p = a->dp;
29 } 30 while (len--) {
31 *p++ = 0;
32 }
30 33
31 /* free ram */ 34 /* free ram */
32 XFREE(a->dp); 35 XFREE(a->dp);
33 36
34 /* reset members to make debugging easier */ 37 /* reset members to make debugging easier */