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/CISOBlob.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'Source/Core/DiscIO/CISOBlob.cpp') diff --git a/Source/Core/DiscIO/CISOBlob.cpp b/Source/Core/DiscIO/CISOBlob.cpp index f9947d0e6c..9c7f440cf9 100644 --- a/Source/Core/DiscIO/CISOBlob.cpp +++ b/Source/Core/DiscIO/CISOBlob.cpp @@ -4,6 +4,7 @@ #include #include +#include #include "Common/CommonTypes.h" #include "Common/FileUtil.h" @@ -29,17 +30,15 @@ CISOFileReader::CISOFileReader(std::FILE* file) m_ciso_map[idx] = (1 == header.map[idx]) ? count++ : UNUSED_BLOCK_ID; } -CISOFileReader* CISOFileReader::Create(const std::string& filename) +std::unique_ptr CISOFileReader::Create(const std::string& filename) { if (IsCISOBlob(filename)) { File::IOFile f(filename, "rb"); - return new CISOFileReader(f.ReleaseHandle()); - } - else - { - return nullptr; + return std::unique_ptr(new CISOFileReader(f.ReleaseHandle())); } + + return nullptr; } u64 CISOFileReader::GetDataSize() const -- cgit v1.2.3