From 0a2c565aa98fa7bc9623a753370e565fc5ed1e63 Mon Sep 17 00:00:00 2001 From: Christopher Bergqvist Date: Thu, 11 Jun 2020 18:02:28 +0200 Subject: Switch from auto_ptr to unique_ptr (#638) --- src/Core/Unix/CoreService.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/Core/Unix/CoreService.cpp') diff --git a/src/Core/Unix/CoreService.cpp b/src/Core/Unix/CoreService.cpp index 2a77c90a..41cc5ec9 100644 --- a/src/Core/Unix/CoreService.cpp +++ b/src/Core/Unix/CoreService.cpp @@ -28,9 +28,9 @@ namespace VeraCrypt { template - auto_ptr CoreService::GetResponse () + unique_ptr CoreService::GetResponse () { - auto_ptr deserializedObject (Serializable::DeserializeNew (ServiceOutputStream)); + unique_ptr deserializedObject (Serializable::DeserializeNew (ServiceOutputStream)); Exception *deserializedException = dynamic_cast (deserializedObject.get()); if (deserializedException) @@ -39,7 +39,7 @@ namespace VeraCrypt if (dynamic_cast (deserializedObject.get()) == nullptr) throw ParameterIncorrect (SRC_POS); - return auto_ptr (dynamic_cast (deserializedObject.release())); + return unique_ptr (dynamic_cast (deserializedObject.release())); } void CoreService::ProcessElevatedRequests () @@ -90,7 +90,7 @@ namespace VeraCrypt { try { - Core = CoreDirect; + Core = std::move(CoreDirect); shared_ptr inputStream (new FileStream (inputFD != -1 ? inputFD : InputPipe->GetReadFD())); shared_ptr outputStream (new FileStream (outputFD != -1 ? outputFD : OutputPipe->GetWriteFD())); @@ -278,7 +278,7 @@ namespace VeraCrypt } template - auto_ptr CoreService::SendRequest (CoreServiceRequest &request) + unique_ptr CoreService::SendRequest (CoreServiceRequest &request) { static Mutex mutex; ScopeLock lock (mutex); @@ -341,7 +341,7 @@ namespace VeraCrypt try { request.Serialize (ServiceInputStream); - auto_ptr response (GetResponse ()); + unique_ptr response (GetResponse ()); ElevatedServiceAvailable = true; return response; } @@ -390,8 +390,8 @@ namespace VeraCrypt void CoreService::StartElevated (const CoreServiceRequest &request) { - auto_ptr inPipe (new Pipe()); - auto_ptr outPipe (new Pipe()); + unique_ptr inPipe (new Pipe()); + unique_ptr outPipe (new Pipe()); Pipe errPipe; int forkedPid = fork(); @@ -533,7 +533,7 @@ namespace VeraCrypt if (!errOutput.empty()) { - auto_ptr deserializedObject; + unique_ptr 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 CoreService::AdminPasswordCallback; - auto_ptr CoreService::AdminInputPipe; - auto_ptr CoreService::AdminOutputPipe; + unique_ptr CoreService::AdminInputPipe; + unique_ptr CoreService::AdminOutputPipe; - auto_ptr CoreService::InputPipe; - auto_ptr CoreService::OutputPipe; + unique_ptr CoreService::InputPipe; + unique_ptr CoreService::OutputPipe; shared_ptr CoreService::ServiceInputStream; shared_ptr CoreService::ServiceOutputStream; -- cgit v1.2.3