FifoDataFile: Convert MemoryUpdate data member to std::vector

This commit is contained in:
Lioncash 2016-06-28 21:38:33 -04:00
parent 8943d23a4c
commit 437b1294bb
5 changed files with 12 additions and 18 deletions

View File

@ -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<MemoryUpdate>& 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<u32>(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<MemoryUpdate::Type>(srcUpdate.type);
file.Seek(srcUpdate.dataOffset, SEEK_SET);
file.ReadBytes(dstUpdate.data, srcUpdate.dataSize);
file.ReadBytes(dstUpdate.data.data(), srcUpdate.dataSize);
}
}

View File

@ -27,8 +27,7 @@ struct MemoryUpdate
u32 fifoPosition;
u32 address;
u32 size;
u8* data;
std::vector<u8> data;
Type type;
};

View File

@ -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)

View File

@ -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)
{

View File

@ -946,8 +946,8 @@ wxString FifoPlayerDlg::CreateRecordingMemSizeLabel() const
for (size_t frameNum = 0; frameNum < file->GetFrameCount(); ++frameNum)
{
const std::vector<MemoryUpdate>& 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);