removed unnecessary allocation

This commit is contained in:
CPunch 2020-08-26 14:23:40 -05:00
parent c9badae526
commit 6db1a7baf1
1 changed files with 1 additions and 5 deletions

View File

@ -202,16 +202,12 @@ void CNSocket::step() {
// decrypt readBuffer and copy to CNPacketData // decrypt readBuffer and copy to CNPacketData
CNSocketEncryption::decryptData((uint8_t*)&readBuffer, (uint8_t*)(&EKey), readSize); CNSocketEncryption::decryptData((uint8_t*)&readBuffer, (uint8_t*)(&EKey), readSize);
void* tmpBuf = xmalloc(readSize-sizeof(int32_t)); void* tmpBuf = readBuffer+sizeof(uint32_t);
memcpy(tmpBuf, readBuffer+sizeof(uint32_t), readSize-sizeof(int32_t));
CNPacketData tmp(tmpBuf, *((uint32_t*)readBuffer), readSize-sizeof(int32_t)); CNPacketData tmp(tmpBuf, *((uint32_t*)readBuffer), readSize-sizeof(int32_t));
// call packet handler!! // call packet handler!!
pHandler(this, &tmp); pHandler(this, &tmp);
// clean up the buffer :)
free(tmpBuf);
// reset vars :) // reset vars :)
readSize = 0; readSize = 0;
readBufferIndex = 0; readBufferIndex = 0;