comparison bn_mp_clear.c @ 283:bd240aa12ba7 libtommath-dropbear

* Changes imported from Dropbear 0.47. * bn_mp_clear.c is changed so that some vars are volatile, so that the compiler won't optimise away
author Matt Johnston <matt@ucc.asn.au>
date Wed, 08 Mar 2006 13:22:52 +0000
parents 91fbc376f010
children 4663ced4968f
comparison
equal deleted inserted replaced
282:91fbc376f010 283:bd240aa12ba7
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 */