summaryrefslogtreecommitdiff
path: root/src/network/core/tcp.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-11-30 13:22:29 +0000
committerrubidium <rubidium@openttd.org>2010-11-30 13:22:29 +0000
commit9c83a8975fe93568d4a3c44bd273e846b18d8e3f (patch)
treef673aa11b963cb6dce5c08220619b7be3d81b439 /src/network/core/tcp.cpp
parent44937dfa5e9b7942ba46c7b2a0f4414b3dc9f0a9 (diff)
downloadopenttd-9c83a8975fe93568d4a3c44bd273e846b18d8e3f.tar.xz
(svn r21357) -Codechange: make it possible to resize the packet's buffer
Diffstat (limited to 'src/network/core/tcp.cpp')
-rw-r--r--src/network/core/tcp.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/network/core/tcp.cpp b/src/network/core/tcp.cpp
index 3f59efba9..c35b029a2 100644
--- a/src/network/core/tcp.cpp
+++ b/src/network/core/tcp.cpp
@@ -63,6 +63,11 @@ void NetworkTCPSocketHandler::Send_Packet(Packet *packet)
packet->PrepareToSend();
+ /* 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);
+
/* Locate last packet buffered for the client */
p = this->packet_queue;
if (p == NULL) {