[ros-diffs] [sginsberg] 41350: - Clean up RtlSecureZeroMemory

sginsberg at svn.reactos.org sginsberg at svn.reactos.org
Mon Jun 8 15:42:03 CEST 2009


Author: sginsberg
Date: Mon Jun  8 17:42:02 2009
New Revision: 41350

URL: http://svn.reactos.org/svn/reactos?rev=41350&view=rev
Log:
- Clean up RtlSecureZeroMemory

Modified:
    trunk/reactos/include/psdk/winnt.h

Modified: trunk/reactos/include/psdk/winnt.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winnt.h?rev=41350&r1=41349&r2=41350&view=diff
==============================================================================
--- trunk/reactos/include/psdk/winnt.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/winnt.h [iso-8859-1] Mon Jun  8 17:42:02 2009
@@ -4688,19 +4688,24 @@
 
 FORCEINLINE
 PVOID
-RtlSecureZeroMemory(IN PVOID ptr,
-                    IN SIZE_T cnt)
+RtlSecureZeroMemory(IN PVOID Buffer,
+                    IN SIZE_T Length)
 {
-    volatile char *vptr = (volatile char *)ptr;
-
-    while (cnt)
+    volatile char *VolatilePointer;
+
+    /* Get a volatile pointer to prevent any compiler optimizations */
+    VolatilePointer = (volatile char *)Buffer;
+
+    /* Loop the whole buffer */
+    while (Length)
     {
-        *vptr = 0;
-        vptr++;
-        cnt--;
+        /* Zero the current byte and move on */
+        *VolatilePointer++ = 0;
+        Length--;
     }
 
-    return ptr;
+    /* Return the pointer to ensure the compiler won't optimize this away */
+    return Buffer;
 }
 
 typedef struct _OBJECT_TYPE_LIST {



More information about the Ros-diffs mailing list