CoreParameter: Use unique_ptr in place of raw pointers

This commit is contained in:
Lioncash 2014-09-27 14:42:59 -04:00
parent 943383c30e
commit 2f4d3961b3
1 changed files with 10 additions and 10 deletions

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <cinttypes>
#include <memory>
#include "Common/CDUtils.h"
#include "Common/CommonPaths.h"
@ -133,7 +134,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
bootDrive)
{
m_BootType = BOOT_ISO;
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(m_strFilename);
std::unique_ptr<DiscIO::IVolume> pVolume(DiscIO::CreateVolumeFromFilename(m_strFilename));
if (pVolume == nullptr)
{
if (bootDrive)
@ -151,7 +152,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
m_strRevisionSpecificUniqueID = pVolume->GetRevisionSpecificUniqueID();
// Check if we have a Wii disc
bWii = DiscIO::IsVolumeWiiDisc(pVolume);
bWii = DiscIO::IsVolumeWiiDisc(pVolume.get());
switch (pVolume->GetCountry())
{
case DiscIO::IVolume::COUNTRY_USA:
@ -182,10 +183,12 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
bNTSC = false;
Region = EUR_DIR;
break;
}else return false;
}
else
{
return false;
}
}
delete pVolume;
}
else if (!strcasecmp(Extension.c_str(), ".elf"))
{
@ -209,17 +212,16 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
bNTSC = true;
m_BootType = BOOT_DFF;
FifoDataFile *ddfFile = FifoDataFile::Load(m_strFilename, true);
std::unique_ptr<FifoDataFile> ddfFile(FifoDataFile::Load(m_strFilename, true));
if (ddfFile)
{
bWii = ddfFile->GetIsWii();
delete ddfFile;
}
}
else if (DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename).IsValid())
{
const DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(m_strFilename);
std::unique_ptr<DiscIO::IVolume> pVolume(DiscIO::CreateVolumeFromFilename(m_strFilename));
const DiscIO::INANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename);
if (ContentLoader.GetContentByIndex(ContentLoader.GetBootIndex()) == nullptr)
@ -267,7 +269,6 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
{
m_strName = pVolume->GetName();
m_strUniqueID = pVolume->GetUniqueID();
delete pVolume;
}
else
{
@ -290,7 +291,6 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
{
m_strUniqueID = titleidstr;
}
}
else
{