mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-31 09:04:14 +00:00
16 bytes alignment for extra buffer
This commit is contained in:
parent
1aae921ce7
commit
4f0c1d11eb
@ -532,10 +532,12 @@ namespace transport
|
|||||||
uint8_t * buf = nullptr, * moreBuf = m_ReceiveBuffer;
|
uint8_t * buf = nullptr, * moreBuf = m_ReceiveBuffer;
|
||||||
if (moreBytes + m_ReceiveBufferOffset > NTCP_BUFFER_SIZE)
|
if (moreBytes + m_ReceiveBufferOffset > NTCP_BUFFER_SIZE)
|
||||||
{
|
{
|
||||||
buf = new uint8_t[moreBytes + m_ReceiveBufferOffset];
|
buf = new uint8_t[moreBytes + m_ReceiveBufferOffset + 16];
|
||||||
if (m_ReceiveBufferOffset)
|
|
||||||
memcpy (buf, m_ReceiveBuffer, m_ReceiveBufferOffset);
|
|
||||||
moreBuf = buf;
|
moreBuf = buf;
|
||||||
|
uint8_t rem = ((size_t)buf) & 0x0f;
|
||||||
|
if (rem) moreBuf += (16 - rem); // align 16
|
||||||
|
if (m_ReceiveBufferOffset)
|
||||||
|
memcpy (moreBuf, m_ReceiveBuffer, m_ReceiveBufferOffset);
|
||||||
}
|
}
|
||||||
moreBytes = m_Socket.read_some (boost::asio::buffer (moreBuf + m_ReceiveBufferOffset, moreBytes), ec);
|
moreBytes = m_Socket.read_some (boost::asio::buffer (moreBuf + m_ReceiveBufferOffset, moreBytes), ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user