VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Platform
diff options
context:
space:
mode:
Diffstat (limited to 'src/Platform')
-rw-r--r--src/Platform/Buffer.cpp2
-rw-r--r--src/Platform/File.h6
-rw-r--r--src/Platform/Memory.cpp6
-rw-r--r--src/Platform/Memory.h2
-rw-r--r--src/Platform/SharedPtr.h17
-rw-r--r--src/Platform/StringConverter.cpp2
-rw-r--r--src/Platform/Unix/Process.cpp2
7 files changed, 26 insertions, 11 deletions
diff --git a/src/Platform/Buffer.cpp b/src/Platform/Buffer.cpp
index 7c61dc4..82c2a3f 100644
--- a/src/Platform/Buffer.cpp
+++ b/src/Platform/Buffer.cpp
@@ -77,7 +77,7 @@ namespace VeraCrypt
void Buffer::Erase ()
{
if (DataSize > 0)
- Memory::Erase (DataPtr, DataSize);
+ burn (DataPtr, DataSize);
}
void Buffer::Free ()
diff --git a/src/Platform/File.h b/src/Platform/File.h
index 09924b2..a8befe3 100644
--- a/src/Platform/File.h
+++ b/src/Platform/File.h
@@ -54,7 +54,11 @@ namespace VeraCrypt
typedef int SystemFileHandleType;
#endif
- File () : FileIsOpen (false), SharedHandle (false) { }
+ File () : FileIsOpen (false), mFileOpenFlags (FlagsNone), SharedHandle (false), FileHandle (0)
+#ifndef TC_WINDOWS
+ ,AccTime(0), ModTime (0)
+#endif
+ { }
virtual ~File ();
void AssignSystemHandle (SystemFileHandleType openFileHandle, bool sharedHandle = true)
diff --git a/src/Platform/Memory.cpp b/src/Platform/Memory.cpp
index 785f758..c4afed6 100644
--- a/src/Platform/Memory.cpp
+++ b/src/Platform/Memory.cpp
@@ -10,7 +10,6 @@
code distribution packages.
*/
-#include "Common/Tcdefs.h"
#include "Memory.h"
#include "Exception.h"
#include <stdlib.h>
@@ -62,11 +61,6 @@ namespace VeraCrypt
memcpy (memoryDestination, memorySource, size);
}
- void Memory::Erase (void *memory, size_t size)
- {
- burn (memory, size);
- }
-
void Memory::Zero (void *memory, size_t size)
{
memset (memory, 0, size);
diff --git a/src/Platform/Memory.h b/src/Platform/Memory.h
index 2b022df..e0d4bfe 100644
--- a/src/Platform/Memory.h
+++ b/src/Platform/Memory.h
@@ -16,6 +16,7 @@
#include <new>
#include <memory.h>
#include "PlatformBase.h"
+#include "Common/Tcdefs.h"
#ifdef TC_WINDOWS
@@ -76,7 +77,6 @@ namespace VeraCrypt
static void *AllocateAligned (size_t size, size_t alignment);
static int Compare (const void *memory1, size_t size1, const void *memory2, size_t size2);
static void Copy (void *memoryDestination, const void *memorySource, size_t size);
- static void Erase (void *memory, size_t size);
static void Free (void *memory);
static void FreeAligned (void *memory);
static void Zero (void *memory, size_t size);
diff --git a/src/Platform/SharedPtr.h b/src/Platform/SharedPtr.h
index 7675c2a..2966971 100644
--- a/src/Platform/SharedPtr.h
+++ b/src/Platform/SharedPtr.h
@@ -14,12 +14,25 @@
#define TC_HEADER_Platform_SharedPtr
#include <stdexcept>
+#include <memory>
#include "SharedVal.h"
#ifdef nullptr
namespace VeraCrypt
{
+#if (__cplusplus >= 201103L)
+ #define VC_USE_NATIVE_PTR 1
+#endif
+
+#ifdef VC_USE_NATIVE_PTR
+
+#define shared_ptr std::shared_ptr
+#define make_shared std::make_shared
+#define move_ptr std::move
+
+#else
+
template <class T>
class SharedPtr
{
@@ -157,6 +170,10 @@ namespace VeraCrypt
#define make_shared VeraCrypt::make_shared
+#define unique_ptr auto_ptr
+#define move_ptr(p) p
+
+#endif
}
#endif // nullptr
diff --git a/src/Platform/StringConverter.cpp b/src/Platform/StringConverter.cpp
index 6975bb3..e1a6df9 100644
--- a/src/Platform/StringConverter.cpp
+++ b/src/Platform/StringConverter.cpp
@@ -233,7 +233,7 @@ namespace VeraCrypt
str.clear();
str.insert (0, &buf.front(), size);
- Memory::Erase (&buf.front(), buf.size());
+ burn (&buf.front(), buf.size());
}
catch (...)
{
diff --git a/src/Platform/Unix/Process.cpp b/src/Platform/Unix/Process.cpp
index a21e118..d148a68 100644
--- a/src/Platform/Unix/Process.cpp
+++ b/src/Platform/Unix/Process.cpp
@@ -170,7 +170,7 @@ namespace VeraCrypt
if (!exOutput.empty())
{
- auto_ptr <Serializable> deserializedObject;
+ unique_ptr <Serializable> deserializedObject;
Exception *deserializedException = nullptr;
try