提交 3a53e93d authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

RTC/TcpConnection: memcpy the packet into a static big buffer

上级 14a3020d
......@@ -4,10 +4,15 @@
#include "RTC/TcpConnection.hpp"
#include "Logger.hpp"
#include "Utils.hpp"
#include <cstring> // std::memmove()
#include <cstring> // std::memmove(), std::memcpy()
namespace RTC
{
/* Static. */
static constexpr size_t ReadBufferSize{ 65536 };
static uint8_t ReadBuffer[ReadBufferSize];
/* Instance methods. */
TcpConnection::TcpConnection(Listener* listener, size_t bufferSize)
......@@ -67,7 +72,12 @@ namespace RTC
if (packetLen != 0)
{
this->recvBytes += packetLen;
this->listener->OnPacketRecv(this, packet, packetLen);
// Copy the received packet into the static buffer so it can be expanded
// later.
std::memcpy(ReadBuffer, packet, packetLen);
this->listener->OnPacketRecv(this, ReadBuffer, packetLen);
}
// If there is no more space available in the buffer and that is because
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论