mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Use automatic storage for the data
This commit is contained in:
parent
52cca29cd9
commit
c4d18118c1
|
@ -1516,16 +1516,10 @@ CServer::CCache::~CCache()
|
|||
|
||||
CServer::CCache::CCacheChunk::CCacheChunk(const void *pData, int Size)
|
||||
{
|
||||
m_pData = malloc(Size); // This can fail, but no way to indicate that barring an exception
|
||||
mem_copy(m_pData, pData, Size);
|
||||
mem_copy(m_aData, pData, Size);
|
||||
m_DataSize = Size;
|
||||
}
|
||||
|
||||
CServer::CCache::CCacheChunk::~CCacheChunk()
|
||||
{
|
||||
free(m_pData);
|
||||
}
|
||||
|
||||
void CServer::CCache::AddChunk(const void *pData, int Size)
|
||||
{
|
||||
m_lCache.emplace_back(pData, Size);
|
||||
|
@ -1747,7 +1741,7 @@ void CServer::SendServerInfo(const NETADDR *pAddr, int Token, int Type, bool Sen
|
|||
}
|
||||
|
||||
ADD_INT(p, Token);
|
||||
p.AddRaw(FirstChunk.m_pData, FirstChunk.m_DataSize);
|
||||
p.AddRaw(FirstChunk.m_aData, FirstChunk.m_DataSize);
|
||||
|
||||
CNetChunk Packet;
|
||||
Packet.m_ClientID = -1;
|
||||
|
@ -1771,10 +1765,10 @@ void CServer::SendServerInfo(const NETADDR *pAddr, int Token, int Type, bool Sen
|
|||
}
|
||||
else if(Type == SERVERINFO_64_LEGACY)
|
||||
{
|
||||
p.AddRaw(FirstChunk.m_pData, FirstChunk.m_DataSize);
|
||||
p.AddRaw(FirstChunk.m_aData, FirstChunk.m_DataSize);
|
||||
}
|
||||
|
||||
p.AddRaw(Chunk.m_pData, Chunk.m_DataSize);
|
||||
p.AddRaw(Chunk.m_aData, Chunk.m_DataSize);
|
||||
Packet.m_pData = p.Data();
|
||||
Packet.m_DataSize = p.Size();
|
||||
m_NetServer.Send(&Packet);
|
||||
|
|
|
@ -299,10 +299,9 @@ public:
|
|||
public:
|
||||
CCacheChunk(const void *pData, int Size);
|
||||
CCacheChunk(const CCacheChunk &) = delete;
|
||||
~CCacheChunk();
|
||||
|
||||
int m_DataSize;
|
||||
void *m_pData;
|
||||
unsigned char *m_aData[NET_MAX_PAYLOAD];
|
||||
};
|
||||
|
||||
std::list<CCacheChunk> m_lCache;
|
||||
|
|
Loading…
Reference in a new issue