mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
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.
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -167,19 +168,14 @@ File::IOFile& WbfsFileReader::SeekToCluster(u64 offset, u64* available)
|
||||
return m_files[0]->file;
|
||||
}
|
||||
|
||||
WbfsFileReader* WbfsFileReader::Create(const std::string& filename)
|
||||
std::unique_ptr<WbfsFileReader> WbfsFileReader::Create(const std::string& filename)
|
||||
{
|
||||
WbfsFileReader* reader = new WbfsFileReader(filename);
|
||||
auto reader = std::unique_ptr<WbfsFileReader>(new WbfsFileReader(filename));
|
||||
|
||||
if (reader->IsGood())
|
||||
{
|
||||
return reader;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete reader;
|
||||
return nullptr;
|
||||
}
|
||||
if (!reader->IsGood())
|
||||
reader.reset();
|
||||
|
||||
return reader;
|
||||
}
|
||||
|
||||
bool IsWbfsBlob(const std::string& filename)
|
||||
|
Reference in New Issue
Block a user