Got unlazy and made message logging using safe pointer, using vectors

This commit is contained in:
phr0z3nt04st
2010-05-27 11:30:12 -05:00
parent a263c980d2
commit e6aa35608f
3 changed files with 16 additions and 17 deletions

View File

@@ -9,22 +9,20 @@ LLMessageLogEntry::LLMessageLogEntry(EType type, LLHost from_host, LLHost to_hos
{ {
if(data) if(data)
{ {
mData = new U8[data_size]; mData.resize(data_size);
memcpy(mData, data, data_size); mData.assign(data,data + data_size);
} }
else }
LLMessageLogEntry::LLMessageLogEntry(EType type, LLHost from_host, LLHost to_host, std::vector<U8> data, S32 data_size)
: mType(type),
mFromHost(from_host),
mToHost(to_host),
mDataSize(data_size),
mData(data)
{ {
mData = NULL;
}
} }
LLMessageLogEntry::~LLMessageLogEntry() 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 U32 LLMessageLog::sMaxSize = 4096; // testzone fixme todo boom
std::deque<LLMessageLogEntry> LLMessageLog::sDeque; std::deque<LLMessageLogEntry> LLMessageLog::sDeque;

View File

@@ -17,12 +17,13 @@ public:
HTTP_RESPONSE 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, U8* data, S32 data_size);
LLMessageLogEntry(EType type, LLHost from_host, LLHost to_host, std::vector<U8> data, S32 data_size);
~LLMessageLogEntry(); ~LLMessageLogEntry();
EType mType; EType mType;
LLHost mFromHost; LLHost mFromHost;
LLHost mToHost; LLHost mToHost;
S32 mDataSize; S32 mDataSize;
U8* mData; std::vector<U8> mData;
}; };
class LLMessageLog class LLMessageLog
{ {

View File

@@ -41,8 +41,8 @@ LLFloaterMessageLogItem::LLFloaterMessageLogItem(LLMessageLogEntry entry)
{ {
BOOL decode_invalid = FALSE; BOOL decode_invalid = FALSE;
S32 decode_len = mDataSize; S32 decode_len = mDataSize;
U8 DecodeBuffer[MAX_PACKET_LEN]; std::vector<U8> DecodeBuffer(MAX_PACKET_LEN,0);
memcpy(DecodeBuffer, mData, decode_len); DecodeBuffer.assign(mData.begin(),mData.end());
mFlags = DecodeBuffer[0]; mFlags = DecodeBuffer[0];
U8* decodep = &(DecodeBuffer[0]); U8* decodep = &(DecodeBuffer[0]);
gMessageSystem->zeroCodeExpand(&decodep, &decode_len); gMessageSystem->zeroCodeExpand(&decodep, &decode_len);
@@ -142,8 +142,8 @@ std::string LLFloaterMessageLogItem::getFull(BOOL show_header)
{ {
BOOL decode_invalid = FALSE; BOOL decode_invalid = FALSE;
S32 decode_len = mDataSize; S32 decode_len = mDataSize;
U8 DecodeBuffer[MAX_PACKET_LEN]; std::vector<U8> DecodeBuffer(MAX_PACKET_LEN,0);
memcpy(DecodeBuffer, mData, decode_len); DecodeBuffer.assign(mData.begin(),mData.end());
U8* decodep = &(DecodeBuffer[0]); U8* decodep = &(DecodeBuffer[0]);
gMessageSystem->zeroCodeExpand(&decodep, &decode_len); gMessageSystem->zeroCodeExpand(&decodep, &decode_len);
if(decode_len < 7) if(decode_len < 7)