diff --git a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp index e918bc993e..d7796056d3 100644 --- a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp +++ b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp @@ -20,9 +20,6 @@ FifoDataFile::~FifoDataFile() { for (auto& frame : m_Frames) { - for (auto& update : frame.memoryUpdates) - delete[] update.data; - delete[] frame.fifoData; } } @@ -234,12 +231,12 @@ u64 FifoDataFile::WriteMemoryUpdates(const std::vector& memUpdates // Write memory file.Seek(0, SEEK_END); u64 dataOffset = file.Tell(); - file.WriteBytes(srcUpdate.data, srcUpdate.size); + file.WriteBytes(srcUpdate.data.data(), srcUpdate.data.size()); FileMemoryUpdate dstUpdate; dstUpdate.address = srcUpdate.address; dstUpdate.dataOffset = dataOffset; - dstUpdate.dataSize = srcUpdate.size; + dstUpdate.dataSize = static_cast(srcUpdate.data.size()); dstUpdate.fifoPosition = srcUpdate.fifoPosition; dstUpdate.type = srcUpdate.type; @@ -266,11 +263,10 @@ void FifoDataFile::ReadMemoryUpdates(u64 fileOffset, u32 numUpdates, MemoryUpdate& dstUpdate = memUpdates[i]; dstUpdate.address = srcUpdate.address; dstUpdate.fifoPosition = srcUpdate.fifoPosition; - dstUpdate.size = srcUpdate.dataSize; - dstUpdate.data = new u8[srcUpdate.dataSize]; - dstUpdate.type = (MemoryUpdate::Type)srcUpdate.type; + dstUpdate.data.resize(srcUpdate.dataSize); + dstUpdate.type = static_cast(srcUpdate.type); file.Seek(srcUpdate.dataOffset, SEEK_SET); - file.ReadBytes(dstUpdate.data, srcUpdate.dataSize); + file.ReadBytes(dstUpdate.data.data(), srcUpdate.dataSize); } } diff --git a/Source/Core/Core/FifoPlayer/FifoDataFile.h b/Source/Core/Core/FifoPlayer/FifoDataFile.h index 8c2d449eb0..269dc34742 100644 --- a/Source/Core/Core/FifoPlayer/FifoDataFile.h +++ b/Source/Core/Core/FifoPlayer/FifoDataFile.h @@ -27,8 +27,7 @@ struct MemoryUpdate u32 fifoPosition; u32 address; - u32 size; - u8* data; + std::vector data; Type type; }; diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp index 99b35a0ad5..322cb019d7 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp @@ -323,7 +323,7 @@ void FifoPlayer::WriteMemory(const MemoryUpdate& memUpdate) else mem = &Memory::m_pRAM[memUpdate.address & Memory::RAM_MASK]; - memcpy(mem, memUpdate.data, memUpdate.size); + std::copy(memUpdate.data.begin(), memUpdate.data.end(), mem); } void FifoPlayer::WriteFifo(u8* data, u32 start, u32 end) diff --git a/Source/Core/Core/FifoPlayer/FifoRecorder.cpp b/Source/Core/Core/FifoPlayer/FifoRecorder.cpp index 2389562a4f..b7858fecda 100644 --- a/Source/Core/Core/FifoPlayer/FifoRecorder.cpp +++ b/Source/Core/Core/FifoPlayer/FifoRecorder.cpp @@ -126,12 +126,11 @@ void FifoRecorder::UseMemory(u32 address, u32 size, MemoryUpdate::Type type, boo MemoryUpdate memUpdate; memUpdate.address = address; memUpdate.fifoPosition = (u32)(m_FifoData.size()); - memUpdate.size = size; memUpdate.type = type; - memUpdate.data = new u8[size]; - memcpy(memUpdate.data, newData, size); + memUpdate.data.resize(size); + std::copy(newData, newData + size, memUpdate.data.begin()); - m_CurrentFrame.memoryUpdates.push_back(memUpdate); + m_CurrentFrame.memoryUpdates.push_back(std::move(memUpdate)); } else if (dynamicUpdate) { diff --git a/Source/Core/DolphinWX/FifoPlayerDlg.cpp b/Source/Core/DolphinWX/FifoPlayerDlg.cpp index 818b9547d2..bffbbc26a3 100644 --- a/Source/Core/DolphinWX/FifoPlayerDlg.cpp +++ b/Source/Core/DolphinWX/FifoPlayerDlg.cpp @@ -946,8 +946,8 @@ wxString FifoPlayerDlg::CreateRecordingMemSizeLabel() const for (size_t frameNum = 0; frameNum < file->GetFrameCount(); ++frameNum) { const std::vector& memUpdates = file->GetFrame(frameNum).memoryUpdates; - for (auto& memUpdate : memUpdates) - memBytes += memUpdate.size; + for (const auto& memUpdate : memUpdates) + memBytes += memUpdate.data.size(); } return wxString::Format(_("%zu memory bytes"), memBytes);