comparison bn_mp_clear.c @ 387:4663ced4968f libtommath-dropbear

propagate from branch 'au.asn.ucc.matt.ltm.orig' (head 1c2b7d389d0682caf980235dad97493e3206389c) to branch 'au.asn.ucc.matt.ltm.dropbear' (head 40ab3795de3a6157f34e52ed3f0be3eebe9a2eaa)
author Matt Johnston <matt@ucc.asn.au>
date Thu, 11 Jan 2007 03:13:04 +0000
parents 97db060d0ef5 bd240aa12ba7
children
comparison
equal deleted inserted replaced
386:97db060d0ef5 387:4663ced4968f
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 */