diff 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
line wrap: on
line diff
--- a/bn_mp_clear.c	Wed Mar 08 13:16:18 2006 +0000
+++ b/bn_mp_clear.c	Wed Mar 08 13:22:52 2006 +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);