Commit 0c777eb1 authored by Chen Bill's avatar Chen Bill

use array index

parent d859ab3c
...@@ -28,7 +28,6 @@ void Replay::BeginRecord() { ...@@ -28,7 +28,6 @@ void Replay::BeginRecord() {
if(!fp) if(!fp)
return; return;
#endif #endif
pwrite = replay_data;
replay_size = 0; replay_size = 0;
comp_size = 0; comp_size = 0;
is_replaying = false; is_replaying = false;
...@@ -47,10 +46,10 @@ void Replay::WriteHeader(ReplayHeader& header) { ...@@ -47,10 +46,10 @@ void Replay::WriteHeader(ReplayHeader& header) {
void Replay::WriteData(const void* data, size_t length, bool flush) { void Replay::WriteData(const void* data, size_t length, bool flush) {
if(!is_recording) if(!is_recording)
return; return;
if ((pwrite - replay_data) + length > MAX_REPLAY_SIZE) if (replay_size + length > MAX_REPLAY_SIZE)
return; return;
std::memcpy(pwrite, data, length); std::memcpy(replay_data + replay_size, data, length);
pwrite += length; replay_size += length;
#ifdef _WIN32 #ifdef _WIN32
DWORD size; DWORD size;
WriteFile(recording_fp, data, length, &size, nullptr); WriteFile(recording_fp, data, length, &size, nullptr);
...@@ -79,7 +78,6 @@ void Replay::EndRecord() { ...@@ -79,7 +78,6 @@ void Replay::EndRecord() {
#else #else
fclose(fp); fclose(fp);
#endif #endif
replay_size = pwrite - replay_data;
pheader.datasize = replay_size; pheader.datasize = replay_size;
pheader.flag |= REPLAY_COMPRESSED; pheader.flag |= REPLAY_COMPRESSED;
size_t propsize = 5; size_t propsize = 5;
......
...@@ -74,7 +74,6 @@ public: ...@@ -74,7 +74,6 @@ public:
private: private:
unsigned char* replay_data; unsigned char* replay_data;
size_t replay_size{}; size_t replay_size{};
unsigned char* pwrite{};
size_t data_position{}; size_t data_position{};
bool is_recording{}; bool is_recording{};
bool is_replaying{}; bool is_replaying{};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment