From 8ada47876a0659f569541397e9b81624ac040467 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 29 Jun 2014 22:30:41 -0400 Subject: [PATCH] Get rid of a few delete[] calls in sdio_slot0.cpp --- .../IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp index e096059f8b..746064d705 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Common/Common.h" #include "Common/SDCardUtil.h" @@ -396,14 +398,14 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(u32 _BufferIn, u32 _BufferInS if (!m_Card.Seek(req.arg, SEEK_SET)) ERROR_LOG(WII_IPC_SD, "Seek failed WTF"); - u8* const buffer = new u8[size]; + std::vector buffer(size); - if (m_Card.ReadBytes(buffer, req.bsize * req.blocks)) + if (m_Card.ReadBytes(buffer.data(), size)) { u32 i; for (i = 0; i < size; ++i) { - Memory::Write_U8((u8)buffer[i], req.addr++); + Memory::Write_U8(buffer[i], req.addr++); } DEBUG_LOG(WII_IPC_SD, "Outbuffer size %i got %i", _rwBufferSize, i); } @@ -413,8 +415,6 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(u32 _BufferIn, u32 _BufferInS ferror(m_Card.GetHandle()), feof(m_Card.GetHandle())); ret = RET_FAIL; } - - delete[] buffer; } } Memory::Write_U32(0x900, _BufferOut); @@ -434,21 +434,19 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(u32 _BufferIn, u32 _BufferInS if (!m_Card.Seek(req.arg, SEEK_SET)) ERROR_LOG(WII_IPC_SD, "fseeko failed WTF"); - u8* buffer = new u8[size]; + std::vector buffer(size); for (u32 i = 0; i < size; ++i) { buffer[i] = Memory::Read_U8(req.addr++); } - if (!m_Card.WriteBytes(buffer, req.bsize * req.blocks)) + if (!m_Card.WriteBytes(buffer.data(), size)) { ERROR_LOG(WII_IPC_SD, "Write Failed - error: %i, eof: %i", ferror(m_Card.GetHandle()), feof(m_Card.GetHandle())); ret = RET_FAIL; } - - delete[] buffer; } } Memory::Write_U32(0x900, _BufferOut);