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