mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-09 07:17:53 +00:00
reduce memory usage
This commit is contained in:
parent
c7edc36106
commit
ad649aba48
@ -553,22 +553,21 @@ namespace transport
|
|||||||
{
|
{
|
||||||
if (!m_NextMessage) // new message, header expected
|
if (!m_NextMessage) // new message, header expected
|
||||||
{
|
{
|
||||||
m_NextMessage = i2p::NewI2NPMessage ();
|
// descrypt header and extract length
|
||||||
m_NextMessageOffset = 0;
|
uint8_t buf[16];
|
||||||
|
m_Decryption.Decrypt (encrypted, buf);
|
||||||
m_Decryption.Decrypt (encrypted, m_NextMessage->buf);
|
uint16_t dataSize = bufbe16toh (buf);
|
||||||
uint16_t dataSize = bufbe16toh (m_NextMessage->buf);
|
|
||||||
if (dataSize)
|
if (dataSize)
|
||||||
{
|
{
|
||||||
// new message
|
// new message
|
||||||
if (dataSize > NTCP_MAX_MESSAGE_SIZE)
|
if (dataSize > NTCP_MAX_MESSAGE_SIZE)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "NTCP data size ", dataSize, " exceeds max size");
|
LogPrint (eLogError, "NTCP data size ", dataSize, " exceeds max size");
|
||||||
i2p::DeleteI2NPMessage (m_NextMessage);
|
|
||||||
m_NextMessage = nullptr;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_NextMessageOffset += 16;
|
m_NextMessage = dataSize <= I2NP_MAX_SHORT_MESSAGE_SIZE - 2 ? NewI2NPShortMessage () : NewI2NPMessage ();
|
||||||
|
memcpy (m_NextMessage->buf, buf, 16);
|
||||||
|
m_NextMessageOffset = 16;
|
||||||
m_NextMessage->offset = 2; // size field
|
m_NextMessage->offset = 2; // size field
|
||||||
m_NextMessage->len = dataSize + 2;
|
m_NextMessage->len = dataSize + 2;
|
||||||
}
|
}
|
||||||
@ -576,8 +575,6 @@ namespace transport
|
|||||||
{
|
{
|
||||||
// timestamp
|
// timestamp
|
||||||
LogPrint ("Timestamp");
|
LogPrint ("Timestamp");
|
||||||
i2p::DeleteI2NPMessage (m_NextMessage);
|
|
||||||
m_NextMessage = nullptr;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user