Avoid unnecessary reallocs in NetworkTCPSocketHandler::SendPacket

This commit is contained in:
Jonathan G Rennison
2019-05-22 06:47:01 +01:00
parent 6bfbd638ac
commit f3aff0fd7f

View File

@@ -70,7 +70,7 @@ void NetworkTCPSocketHandler::SendPacket(Packet *packet)
/* Reallocate the packet as in 99+% of the times we send at most 25 bytes and
* keeping the other 1400+ bytes wastes memory, especially when someone tries
* to do a denial of service attack! */
packet->buffer = ReallocT(packet->buffer, packet->size);
if (packet->size < ((SHRT_MAX * 2) / 3)) packet->buffer = ReallocT(packet->buffer, packet->size);
/* Locate last packet buffered for the client */
p = this->packet_queue;