mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 19:08:26 -06:00
Linux/MacOSX: use standard std::shared_ptr instead of our custom implementation which is kept for compatibility with older compilers. We also introduce compatibility code for old compilers that don't define std::unique_ptr
This commit is contained in:
@@ -548,8 +548,8 @@ namespace VeraCrypt
|
|||||||
if (status != CKR_OK)
|
if (status != CKR_OK)
|
||||||
throw Pkcs11Exception (status);
|
throw Pkcs11Exception (status);
|
||||||
|
|
||||||
PinCallback = std::move(pinCallback);
|
PinCallback = move_ptr(pinCallback);
|
||||||
WarningCallback = std::move(warningCallback);
|
WarningCallback = move_ptr(warningCallback);
|
||||||
|
|
||||||
Initialized = true;
|
Initialized = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,7 +254,11 @@ namespace VeraCrypt
|
|||||||
|
|
||||||
bool CoreBase::IsVolumeMounted (const VolumePath &volumePath) const
|
bool CoreBase::IsVolumeMounted (const VolumePath &volumePath) const
|
||||||
{
|
{
|
||||||
return GetMountedVolume (volumePath);
|
shared_ptr<VolumeInfo> mountedVolume = GetMountedVolume (volumePath);
|
||||||
|
if (mountedVolume)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr <Volume> CoreBase::OpenVolume (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr<Pkcs5Kdf> kdf, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, VolumeProtection::Enum protection, shared_ptr <VolumePassword> protectionPassword, int protectionPim, shared_ptr<Pkcs5Kdf> protectionKdf, shared_ptr <KeyfileList> protectionKeyfiles, bool sharedAccessAllowed, VolumeType::Enum volumeType, bool useBackupHeaders, bool partitionInSystemEncryptionScope) const
|
shared_ptr <Volume> CoreBase::OpenVolume (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr<Pkcs5Kdf> kdf, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, VolumeProtection::Enum protection, shared_ptr <VolumePassword> protectionPassword, int protectionPim, shared_ptr<Pkcs5Kdf> protectionKdf, shared_ptr <KeyfileList> protectionKeyfiles, bool sharedAccessAllowed, VolumeType::Enum volumeType, bool useBackupHeaders, bool partitionInSystemEncryptionScope) const
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ namespace VeraCrypt
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Core = std::move(CoreDirect);
|
Core = move_ptr(CoreDirect);
|
||||||
|
|
||||||
shared_ptr <Stream> inputStream (new FileStream (inputFD != -1 ? inputFD : InputPipe->GetReadFD()));
|
shared_ptr <Stream> inputStream (new FileStream (inputFD != -1 ? inputFD : InputPipe->GetReadFD()));
|
||||||
shared_ptr <Stream> outputStream (new FileStream (outputFD != -1 ? outputFD : OutputPipe->GetWriteFD()));
|
shared_ptr <Stream> outputStream (new FileStream (outputFD != -1 ? outputFD : OutputPipe->GetWriteFD()));
|
||||||
@@ -573,8 +573,8 @@ namespace VeraCrypt
|
|||||||
byte sync[] = { 0, 0x11, 0x22 };
|
byte sync[] = { 0, 0x11, 0x22 };
|
||||||
ServiceInputStream->Write (ConstBufferPtr (sync, array_capacity (sync)));
|
ServiceInputStream->Write (ConstBufferPtr (sync, array_capacity (sync)));
|
||||||
|
|
||||||
AdminInputPipe = std::move(inPipe);
|
AdminInputPipe = move_ptr(inPipe);
|
||||||
AdminOutputPipe = std::move(outPipe);
|
AdminOutputPipe = move_ptr(outPipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreService::Stop ()
|
void CoreService::Stop ()
|
||||||
|
|||||||
@@ -14,12 +14,25 @@
|
|||||||
#define TC_HEADER_Platform_SharedPtr
|
#define TC_HEADER_Platform_SharedPtr
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <memory>
|
||||||
#include "SharedVal.h"
|
#include "SharedVal.h"
|
||||||
|
|
||||||
#ifdef nullptr
|
#ifdef nullptr
|
||||||
|
|
||||||
namespace VeraCrypt
|
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>
|
template <class T>
|
||||||
class SharedPtr
|
class SharedPtr
|
||||||
{
|
{
|
||||||
@@ -157,6 +170,10 @@ namespace VeraCrypt
|
|||||||
|
|
||||||
#define make_shared VeraCrypt::make_shared
|
#define make_shared VeraCrypt::make_shared
|
||||||
|
|
||||||
|
#define unique_ptr auto_ptr
|
||||||
|
#define move_ptr(p) p
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // nullptr
|
#endif // nullptr
|
||||||
|
|||||||
@@ -125,7 +125,9 @@ namespace VeraCrypt
|
|||||||
|
|
||||||
firstFragmentWorkItem->ItemCompletedEvent.Wait();
|
firstFragmentWorkItem->ItemCompletedEvent.Wait();
|
||||||
|
|
||||||
unique_ptr <Exception> itemException = std::move(firstFragmentWorkItem->ItemException);
|
unique_ptr <Exception> itemException;
|
||||||
|
if (firstFragmentWorkItem->ItemException.get())
|
||||||
|
itemException = move_ptr(firstFragmentWorkItem->ItemException);
|
||||||
|
|
||||||
firstFragmentWorkItem->State.Set (WorkItem::State::Free);
|
firstFragmentWorkItem->State.Set (WorkItem::State::Free);
|
||||||
WorkItemCompletedEvent.Signal();
|
WorkItemCompletedEvent.Signal();
|
||||||
|
|||||||
Reference in New Issue
Block a user