From e6aa35608fa4259da5f7d38cf467741a66bcacc0 Mon Sep 17 00:00:00 2001 From: phr0z3nt04st Date: Thu, 27 May 2010 11:30:12 -0500 Subject: [PATCH] Got unlazy and made message logging using safe pointer, using vectors --- indra/llmessage/llmessagelog.cpp | 22 ++++++++++------------ indra/llmessage/llmessagelog.h | 3 ++- indra/newview/llfloatermessagelog.cpp | 8 ++++---- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/indra/llmessage/llmessagelog.cpp b/indra/llmessage/llmessagelog.cpp index d62af6993..73304d7ab 100644 --- a/indra/llmessage/llmessagelog.cpp +++ b/indra/llmessage/llmessagelog.cpp @@ -9,22 +9,20 @@ LLMessageLogEntry::LLMessageLogEntry(EType type, LLHost from_host, LLHost to_hos { if(data) { - mData = new U8[data_size]; - memcpy(mData, data, data_size); - } - else - { - mData = NULL; + mData.resize(data_size); + mData.assign(data,data + data_size); } } +LLMessageLogEntry::LLMessageLogEntry(EType type, LLHost from_host, LLHost to_host, std::vector data, S32 data_size) +: mType(type), + mFromHost(from_host), + mToHost(to_host), + mDataSize(data_size), + mData(data) +{ +} LLMessageLogEntry::~LLMessageLogEntry() { - // wtf, I'm not supposed to do this? - /*if(mData && mDataSize) - { - delete[] mData; - mData = NULL; - }*/ } U32 LLMessageLog::sMaxSize = 4096; // testzone fixme todo boom std::deque LLMessageLog::sDeque; diff --git a/indra/llmessage/llmessagelog.h b/indra/llmessage/llmessagelog.h index 16a652984..9467a2a0f 100644 --- a/indra/llmessage/llmessagelog.h +++ b/indra/llmessage/llmessagelog.h @@ -17,12 +17,13 @@ public: HTTP_RESPONSE }; LLMessageLogEntry(EType type, LLHost from_host, LLHost to_host, U8* data, S32 data_size); + LLMessageLogEntry(EType type, LLHost from_host, LLHost to_host, std::vector data, S32 data_size); ~LLMessageLogEntry(); EType mType; LLHost mFromHost; LLHost mToHost; S32 mDataSize; - U8* mData; + std::vector mData; }; class LLMessageLog { diff --git a/indra/newview/llfloatermessagelog.cpp b/indra/newview/llfloatermessagelog.cpp index 8bf9a12bf..ff82f8ad8 100644 --- a/indra/newview/llfloatermessagelog.cpp +++ b/indra/newview/llfloatermessagelog.cpp @@ -41,8 +41,8 @@ LLFloaterMessageLogItem::LLFloaterMessageLogItem(LLMessageLogEntry entry) { BOOL decode_invalid = FALSE; S32 decode_len = mDataSize; - U8 DecodeBuffer[MAX_PACKET_LEN]; - memcpy(DecodeBuffer, mData, decode_len); + std::vector DecodeBuffer(MAX_PACKET_LEN,0); + DecodeBuffer.assign(mData.begin(),mData.end()); mFlags = DecodeBuffer[0]; U8* decodep = &(DecodeBuffer[0]); gMessageSystem->zeroCodeExpand(&decodep, &decode_len); @@ -142,8 +142,8 @@ std::string LLFloaterMessageLogItem::getFull(BOOL show_header) { BOOL decode_invalid = FALSE; S32 decode_len = mDataSize; - U8 DecodeBuffer[MAX_PACKET_LEN]; - memcpy(DecodeBuffer, mData, decode_len); + std::vector DecodeBuffer(MAX_PACKET_LEN,0); + DecodeBuffer.assign(mData.begin(),mData.end()); U8* decodep = &(DecodeBuffer[0]); gMessageSystem->zeroCodeExpand(&decodep, &decode_len); if(decode_len < 7)