mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
Switch from auto_ptr to unique_ptr (#638)
This commit is contained in:
committed by
GitHub
parent
8250e83e61
commit
0a2c565aa9
@@ -17,8 +17,8 @@
|
||||
|
||||
namespace VeraCrypt
|
||||
{
|
||||
extern auto_ptr <CoreBase> Core;
|
||||
extern auto_ptr <CoreBase> CoreDirect;
|
||||
extern unique_ptr <CoreBase> Core;
|
||||
extern unique_ptr <CoreBase> CoreDirect;
|
||||
|
||||
class WaitThreadRoutine
|
||||
{
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
namespace VeraCrypt
|
||||
{
|
||||
template <class T>
|
||||
auto_ptr <T> CoreService::GetResponse ()
|
||||
unique_ptr <T> CoreService::GetResponse ()
|
||||
{
|
||||
auto_ptr <Serializable> deserializedObject (Serializable::DeserializeNew (ServiceOutputStream));
|
||||
unique_ptr <Serializable> deserializedObject (Serializable::DeserializeNew (ServiceOutputStream));
|
||||
|
||||
Exception *deserializedException = dynamic_cast <Exception*> (deserializedObject.get());
|
||||
if (deserializedException)
|
||||
@@ -39,7 +39,7 @@ namespace VeraCrypt
|
||||
if (dynamic_cast <T *> (deserializedObject.get()) == nullptr)
|
||||
throw ParameterIncorrect (SRC_POS);
|
||||
|
||||
return auto_ptr <T> (dynamic_cast <T *> (deserializedObject.release()));
|
||||
return unique_ptr <T> (dynamic_cast <T *> (deserializedObject.release()));
|
||||
}
|
||||
|
||||
void CoreService::ProcessElevatedRequests ()
|
||||
@@ -90,7 +90,7 @@ namespace VeraCrypt
|
||||
{
|
||||
try
|
||||
{
|
||||
Core = CoreDirect;
|
||||
Core = std::move(CoreDirect);
|
||||
|
||||
shared_ptr <Stream> inputStream (new FileStream (inputFD != -1 ? inputFD : InputPipe->GetReadFD()));
|
||||
shared_ptr <Stream> outputStream (new FileStream (outputFD != -1 ? outputFD : OutputPipe->GetWriteFD()));
|
||||
@@ -278,7 +278,7 @@ namespace VeraCrypt
|
||||
}
|
||||
|
||||
template <class T>
|
||||
auto_ptr <T> CoreService::SendRequest (CoreServiceRequest &request)
|
||||
unique_ptr <T> CoreService::SendRequest (CoreServiceRequest &request)
|
||||
{
|
||||
static Mutex mutex;
|
||||
ScopeLock lock (mutex);
|
||||
@@ -341,7 +341,7 @@ namespace VeraCrypt
|
||||
try
|
||||
{
|
||||
request.Serialize (ServiceInputStream);
|
||||
auto_ptr <T> response (GetResponse <T>());
|
||||
unique_ptr <T> response (GetResponse <T>());
|
||||
ElevatedServiceAvailable = true;
|
||||
return response;
|
||||
}
|
||||
@@ -390,8 +390,8 @@ namespace VeraCrypt
|
||||
|
||||
void CoreService::StartElevated (const CoreServiceRequest &request)
|
||||
{
|
||||
auto_ptr <Pipe> inPipe (new Pipe());
|
||||
auto_ptr <Pipe> outPipe (new Pipe());
|
||||
unique_ptr <Pipe> inPipe (new Pipe());
|
||||
unique_ptr <Pipe> outPipe (new Pipe());
|
||||
Pipe errPipe;
|
||||
|
||||
int forkedPid = fork();
|
||||
@@ -533,7 +533,7 @@ namespace VeraCrypt
|
||||
|
||||
if (!errOutput.empty())
|
||||
{
|
||||
auto_ptr <Serializable> deserializedObject;
|
||||
unique_ptr <Serializable> deserializedObject;
|
||||
Exception *deserializedException = nullptr;
|
||||
|
||||
try
|
||||
@@ -573,8 +573,8 @@ namespace VeraCrypt
|
||||
byte sync[] = { 0, 0x11, 0x22 };
|
||||
ServiceInputStream->Write (ConstBufferPtr (sync, array_capacity (sync)));
|
||||
|
||||
AdminInputPipe = inPipe;
|
||||
AdminOutputPipe = outPipe;
|
||||
AdminInputPipe = std::move(inPipe);
|
||||
AdminOutputPipe = std::move(outPipe);
|
||||
}
|
||||
|
||||
void CoreService::Stop ()
|
||||
@@ -585,11 +585,11 @@ namespace VeraCrypt
|
||||
|
||||
shared_ptr <GetStringFunctor> CoreService::AdminPasswordCallback;
|
||||
|
||||
auto_ptr <Pipe> CoreService::AdminInputPipe;
|
||||
auto_ptr <Pipe> CoreService::AdminOutputPipe;
|
||||
unique_ptr <Pipe> CoreService::AdminInputPipe;
|
||||
unique_ptr <Pipe> CoreService::AdminOutputPipe;
|
||||
|
||||
auto_ptr <Pipe> CoreService::InputPipe;
|
||||
auto_ptr <Pipe> CoreService::OutputPipe;
|
||||
unique_ptr <Pipe> CoreService::InputPipe;
|
||||
unique_ptr <Pipe> CoreService::OutputPipe;
|
||||
shared_ptr <Stream> CoreService::ServiceInputStream;
|
||||
shared_ptr <Stream> CoreService::ServiceOutputStream;
|
||||
|
||||
|
||||
@@ -39,17 +39,17 @@ namespace VeraCrypt
|
||||
static void Stop ();
|
||||
|
||||
protected:
|
||||
template <class T> static auto_ptr <T> GetResponse ();
|
||||
template <class T> static auto_ptr <T> SendRequest (CoreServiceRequest &request);
|
||||
template <class T> static unique_ptr <T> GetResponse ();
|
||||
template <class T> static unique_ptr <T> SendRequest (CoreServiceRequest &request);
|
||||
static void StartElevated (const CoreServiceRequest &request);
|
||||
|
||||
static shared_ptr <GetStringFunctor> AdminPasswordCallback;
|
||||
|
||||
static auto_ptr <Pipe> AdminInputPipe;
|
||||
static auto_ptr <Pipe> AdminOutputPipe;
|
||||
static unique_ptr <Pipe> AdminInputPipe;
|
||||
static unique_ptr <Pipe> AdminOutputPipe;
|
||||
|
||||
static auto_ptr <Pipe> InputPipe;
|
||||
static auto_ptr <Pipe> OutputPipe;
|
||||
static unique_ptr <Pipe> InputPipe;
|
||||
static unique_ptr <Pipe> OutputPipe;
|
||||
static shared_ptr <Stream> ServiceInputStream;
|
||||
static shared_ptr <Stream> ServiceOutputStream;
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace VeraCrypt
|
||||
}
|
||||
|
||||
#ifdef TC_FREEBSD
|
||||
auto_ptr <CoreBase> Core (new CoreServiceProxy <CoreFreeBSD>);
|
||||
auto_ptr <CoreBase> CoreDirect (new CoreFreeBSD);
|
||||
unique_ptr <CoreBase> Core (new CoreServiceProxy <CoreFreeBSD>);
|
||||
unique_ptr <CoreBase> CoreDirect (new CoreFreeBSD);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -489,6 +489,6 @@ namespace VeraCrypt
|
||||
}
|
||||
}
|
||||
|
||||
auto_ptr <CoreBase> Core (new CoreServiceProxy <CoreLinux>);
|
||||
auto_ptr <CoreBase> CoreDirect (new CoreLinux);
|
||||
unique_ptr <CoreBase> Core (new CoreServiceProxy <CoreLinux>);
|
||||
unique_ptr <CoreBase> CoreDirect (new CoreLinux);
|
||||
}
|
||||
|
||||
@@ -229,6 +229,6 @@ namespace VeraCrypt
|
||||
}
|
||||
}
|
||||
|
||||
auto_ptr <CoreBase> Core (new CoreServiceProxy <CoreMacOSX>);
|
||||
auto_ptr <CoreBase> CoreDirect (new CoreMacOSX);
|
||||
unique_ptr <CoreBase> Core (new CoreServiceProxy <CoreMacOSX>);
|
||||
unique_ptr <CoreBase> CoreDirect (new CoreMacOSX);
|
||||
}
|
||||
|
||||
@@ -173,6 +173,6 @@ namespace VeraCrypt
|
||||
}
|
||||
}
|
||||
|
||||
auto_ptr <CoreBase> Core (new CoreServiceProxy <CoreSolaris>);
|
||||
auto_ptr <CoreBase> CoreDirect (new CoreSolaris);
|
||||
unique_ptr <CoreBase> Core (new CoreServiceProxy <CoreSolaris>);
|
||||
unique_ptr <CoreBase> CoreDirect (new CoreSolaris);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user