Avatarchik / lidgren-network-gen3

Automatically exported from code.google.com/p/lidgren-network-gen3
0 stars 0 forks source link

NetOutgoingMessage.Write(string source) bug #19

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
http://code.google.com/p/lidgren-network-gen3/source/browse/trunk/Lidgren.Networ
k/NetOutgoingMessage.Write.cs#521

Original issue reported on code.google.com by imho.sapiens@gmail.com on 2 Aug 2010 at 2:40

GoogleCodeExporter commented 8 years ago
I assume you mean that EnsureBufferSize only allocates 1 byte for string length 
tho it can be larger? It would be possible to calculate the exact number of 
bytes required for the actual length data, but since it's an edge case (most 
strings can be assumed to be smaller than 127 characters) it's faster just to 
ensure the minimum length and if it turns out to be larger, 
WriteVariableUInt32() will itself call EnsureBufferSize and allocate enough 
space.

Original comment by lidg...@gmail.com on 5 Aug 2010 at 2:03

GoogleCodeExporter commented 8 years ago
EnsureBufferSize(m_bitLength + 8 + bytes.Length * 8);

Original comment by imho.sapiens@gmail.com on 7 Aug 2010 at 12:41

GoogleCodeExporter commented 8 years ago
Ah, bits instead of bytes, thanks, missed that! Fixed in rev 89

Original comment by lidg...@gmail.com on 7 Aug 2010 at 7:46