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/FileBlob.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Source/Core/DiscIO/FileBlob.cpp') diff --git a/Source/Core/DiscIO/FileBlob.cpp b/Source/Core/DiscIO/FileBlob.cpp index 3e702d650c..79b66b37bc 100644 --- a/Source/Core/DiscIO/FileBlob.cpp +++ b/Source/Core/DiscIO/FileBlob.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include #include #include "DiscIO/FileBlob.h" @@ -14,13 +15,13 @@ PlainFileReader::PlainFileReader(std::FILE* file) m_size = m_file.GetSize(); } -PlainFileReader* PlainFileReader::Create(const std::string& filename) +std::unique_ptr PlainFileReader::Create(const std::string& filename) { File::IOFile f(filename, "rb"); if (f) - return new PlainFileReader(f.ReleaseHandle()); - else - return nullptr; + return std::unique_ptr(new PlainFileReader(f.ReleaseHandle())); + + return nullptr; } bool PlainFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr) -- cgit v1.2.3