From edbbf493f807ed94b9b32cfb7463f9b7f8f27852 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 6 Dec 2015 23:15:51 -0500 Subject: DiscIO: Make factory methods return unique_ptrs Rather than rely on the developer to do the right thing, just make the default behavior safely deallocate resources. If shared semantics are ever needed in the future, the constructor that takes a unique_ptr for shared_ptr can be used. --- Source/Core/DiscIO/DriveBlob.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'Source/Core/DiscIO/DriveBlob.cpp') diff --git a/Source/Core/DiscIO/DriveBlob.cpp b/Source/Core/DiscIO/DriveBlob.cpp index 07105a9170..efd78db82e 100644 --- a/Source/Core/DiscIO/DriveBlob.cpp +++ b/Source/Core/DiscIO/DriveBlob.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include "Common/CommonTypes.h" @@ -84,15 +85,12 @@ DriveReader::~DriveReader() #endif } -DriveReader* DriveReader::Create(const std::string& drive) +std::unique_ptr DriveReader::Create(const std::string& drive) { - DriveReader* reader = new DriveReader(drive); + auto reader = std::unique_ptr(new DriveReader(drive)); if (!reader->IsOK()) - { - delete reader; - return nullptr; - } + reader.reset(); return reader; } -- cgit v1.2.3