Merge pull request #1652 from lioncash/delete
DiscIO: Remove some explicit deletes
This commit is contained in:
commit
c617b6c722
|
@ -11,7 +11,9 @@
|
|||
#include <cinttypes>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <zlib.h>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
@ -303,21 +305,18 @@ bool DecompressBlobToFile(const std::string& infile, const std::string& outfile,
|
|||
return false;
|
||||
}
|
||||
|
||||
CompressedBlobReader* reader = CompressedBlobReader::Create(infile);
|
||||
std::unique_ptr<CompressedBlobReader> reader(CompressedBlobReader::Create(infile));
|
||||
if (!reader)
|
||||
return false;
|
||||
|
||||
File::IOFile f(outfile, "wb");
|
||||
if (!f)
|
||||
{
|
||||
delete reader;
|
||||
return false;
|
||||
}
|
||||
|
||||
const CompressedBlobHeader &header = reader->GetHeader();
|
||||
static const size_t BUFFER_BLOCKS = 32;
|
||||
size_t buffer_size = header.block_size * BUFFER_BLOCKS;
|
||||
u8* buffer = new u8[buffer_size];
|
||||
std::vector<u8> buffer(buffer_size);
|
||||
u32 num_buffers = header.num_blocks / BUFFER_BLOCKS;
|
||||
int progress_monitor = std::max<int>(1, num_buffers / 100);
|
||||
bool was_cancelled = false;
|
||||
|
@ -330,12 +329,10 @@ bool DecompressBlobToFile(const std::string& infile, const std::string& outfile,
|
|||
if (was_cancelled)
|
||||
break;
|
||||
}
|
||||
reader->Read(i * buffer_size, buffer_size, buffer);
|
||||
f.WriteBytes(buffer, buffer_size);
|
||||
reader->Read(i * buffer_size, buffer_size, buffer.data());
|
||||
f.WriteBytes(buffer.data(), buffer_size);
|
||||
}
|
||||
|
||||
delete[] buffer;
|
||||
|
||||
if (was_cancelled)
|
||||
{
|
||||
// Remove the incomplete output file.
|
||||
|
@ -347,8 +344,6 @@ bool DecompressBlobToFile(const std::string& infile, const std::string& outfile,
|
|||
f.Resize(header.data_size);
|
||||
}
|
||||
|
||||
delete reader;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const
|
|||
_dbg_assert_(DVDINTERFACE, fileIter->first <= _Offset);
|
||||
u64 fileOffset = _Offset - fileIter->first;
|
||||
|
||||
PlainFileReader* reader = PlainFileReader::Create(fileIter->second);
|
||||
std::unique_ptr<PlainFileReader> reader(PlainFileReader::Create(fileIter->second));
|
||||
if (reader == nullptr)
|
||||
return false;
|
||||
|
||||
|
@ -139,8 +139,6 @@ bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const
|
|||
_dbg_assert_(DVDINTERFACE, fileIter->first >= _Offset);
|
||||
PadToAddress(fileIter->first, _Offset, _Length, _pBuffer);
|
||||
}
|
||||
|
||||
delete reader;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue