mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-02-03 04:05:49 +01:00
Use std::make_unique instead of new for arrays
This commit is contained in:
@@ -185,7 +185,7 @@ bool SpriteFile::Save(const utf8* path)
|
|||||||
static bool SpriteImageExport(const rct_g1_element& spriteElement, const char* outPath)
|
static bool SpriteImageExport(const rct_g1_element& spriteElement, const char* outPath)
|
||||||
{
|
{
|
||||||
const auto pixelBufferSize = spriteElement.width * spriteElement.height;
|
const auto pixelBufferSize = spriteElement.width * spriteElement.height;
|
||||||
std::unique_ptr<uint8_t[]> pixelBuffer(new uint8_t[pixelBufferSize]);
|
auto pixelBuffer = std::make_unique<uint8_t[]>(pixelBufferSize);
|
||||||
auto pixels = pixelBuffer.get();
|
auto pixels = pixelBuffer.get();
|
||||||
std::fill_n(pixels, pixelBufferSize, 0x00);
|
std::fill_n(pixels, pixelBufferSize, 0x00);
|
||||||
|
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ template<> struct DataSerializerTraits_t<OpenRCT2::MemoryStream>
|
|||||||
uint32_t length = 0;
|
uint32_t length = 0;
|
||||||
s.decode(stream, length);
|
s.decode(stream, length);
|
||||||
|
|
||||||
std::unique_ptr<uint8_t[]> buf(new uint8_t[length]);
|
auto buf = std::make_unique<uint8_t[]>(length);
|
||||||
stream->Read(buf.get(), length);
|
stream->Read(buf.get(), length);
|
||||||
|
|
||||||
val.Write(buf.get(), length);
|
val.Write(buf.get(), length);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ std::shared_ptr<SawyerChunk> SawyerChunkReader::ReadChunk()
|
|||||||
case CHUNK_ENCODING_RLECOMPRESSED:
|
case CHUNK_ENCODING_RLECOMPRESSED:
|
||||||
case CHUNK_ENCODING_ROTATE:
|
case CHUNK_ENCODING_ROTATE:
|
||||||
{
|
{
|
||||||
std::unique_ptr<uint8_t[]> compressedData(new uint8_t[header.length]);
|
auto compressedData = std::make_unique<uint8_t[]>(header.length);
|
||||||
if (_stream->TryRead(compressedData.get(), header.length) != header.length)
|
if (_stream->TryRead(compressedData.get(), header.length) != header.length)
|
||||||
{
|
{
|
||||||
throw SawyerChunkException(EXCEPTION_MSG_CORRUPT_CHUNK_SIZE);
|
throw SawyerChunkException(EXCEPTION_MSG_CORRUPT_CHUNK_SIZE);
|
||||||
|
|||||||
Reference in New Issue
Block a user