Mercurial > dropbear
comparison bn_mp_clear.c @ 163:8e94663164c6 libtommath LTM_DB_0.44
make pointers volatile so that memory zeroing won't get optimised away
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 02 Jan 2005 17:09:26 +0000 |
parents | d29b64170cf0 |
children |
comparison
equal
deleted
inserted
replaced
157:3a616069cc21 | 163:8e94663164c6 |
---|---|
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 */ |