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)
{
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<U8> 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<LLMessageLogEntry> LLMessageLog::sDeque;

View File

@@ -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<U8> data, S32 data_size);
~LLMessageLogEntry();
EType mType;
LLHost mFromHost;
LLHost mToHost;
S32 mDataSize;
U8* mData;
std::vector<U8> mData;
};
class LLMessageLog
{

View File

@@ -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<U8> 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<U8> DecodeBuffer(MAX_PACKET_LEN,0);
DecodeBuffer.assign(mData.begin(),mData.end());
U8* decodep = &(DecodeBuffer[0]);
gMessageSystem->zeroCodeExpand(&decodep, &decode_len);
if(decode_len < 7)