Minimal code changes to allow msvc compilation.

This commit is contained in:
Aaron Clauson
2017-11-10 07:06:49 +11:00
parent 1f4375f8e7
commit fbf327b138
8 changed files with 23 additions and 9 deletions

View File

@@ -7,6 +7,10 @@
#include <cstring>
#if defined(_MSC_VER)
#include <Windows.h> // For SecureZeroMemory.
#endif
/* Compilers have a bad habit of removing "superfluous" memset calls that
* are trying to zero memory. For example, when memset()ing a buffer and
* then free()ing it, the compiler might decide that the memset is
@@ -32,7 +36,7 @@ void memory_cleanse(void *ptr, size_t len)
might try to eliminate "superfluous" memsets. If there's an easy way to
detect memset_s, it would be better to use that. */
#if defined(_MSC_VER)
__asm;
SecureZeroMemory(ptr, len);
#else
__asm__ __volatile__("" : : "r"(ptr) : "memory");
#endif