summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Base/SafeAllocator.cpp')
-rw-r--r--Swiften/Base/SafeAllocator.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/Swiften/Base/SafeAllocator.cpp b/Swiften/Base/SafeAllocator.cpp
new file mode 100644
index 0000000..d61d8b9
--- /dev/null
+++ b/Swiften/Base/SafeAllocator.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swiften/Base/SafeByteArray.h>
+
+#include <Swiften/Base/Platform.h>
+#ifdef SWIFTEN_PLATFORM_WINDOWS
+#include <windows.h>
+#endif
+
+namespace Swift {
+
+void secureZeroMemory(char* memory, size_t numberOfBytes) {
+#ifdef SWIFTEN_PLATFORM_WINDOWS
+ SecureZeroMemory(memory, numberOfBytes);
+#else
+ volatile char* p = memory;
+ for (size_t i = 0; i < numberOfBytes; ++i) {
+ *(p++) = 0;
+ }
+#endif
+}
+
+}