diff 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
line wrap: on
line diff
--- a/bn_mp_clear.c	Wed Dec 22 16:13:44 2004 +0000
+++ b/bn_mp_clear.c	Sun Jan 02 17:09:26 2005 +0000
@@ -19,14 +19,17 @@
 void
 mp_clear (mp_int * a)
 {
-  int i;
+  volatile mp_digit *p;
+  int len;
 
   /* only do anything if a hasn't been freed previously */
   if (a->dp != NULL) {
     /* first zero the digits */
-    for (i = 0; i < a->used; i++) {
-        a->dp[i] = 0;
-    }
+	len = a->alloc;
+	p = a->dp;
+	while (len--) {
+		*p++ = 0;
+	}
 
     /* free ram */
     XFREE(a->dp);