mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 12:19:12 +00: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:
parent
a0ac2b8673
commit
edbbf493f8
22 changed files with 204 additions and 231 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
@ -84,15 +85,12 @@ DriveReader::~DriveReader()
|
|||
#endif
|
||||
}
|
||||
|
||||
DriveReader* DriveReader::Create(const std::string& drive)
|
||||
std::unique_ptr<DriveReader> DriveReader::Create(const std::string& drive)
|
||||
{
|
||||
DriveReader* reader = new DriveReader(drive);
|
||||
auto reader = std::unique_ptr<DriveReader>(new DriveReader(drive));
|
||||
|
||||
if (!reader->IsOK())
|
||||
{
|
||||
delete reader;
|
||||
return nullptr;
|
||||
}
|
||||
reader.reset();
|
||||
|
||||
return reader;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue