MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / WriteBytes

Method WriteBytes

Source/Engine/Networking/NetworkStream.cpp:239–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239void NetworkStream::WriteBytes(const void* data, uint32 bytes)
240{
241 // Calculate current position
242 const uint32 position = GetPosition();
243
244 // Check if there is need to update a buffer size
245 if (_length - position < bytes)
246 {
247 // Perform reallocation
248 uint32 newLength = _length != 0 ? _length * 2 : 256;
249 while (newLength < position + bytes)
250 newLength *= 2;
251 PROFILE_MEM(Networking);
252 byte* newBuf = (byte*)Allocator::Allocate(newLength);
253 if (_buffer && _length)
254 Platform::MemoryCopy(newBuf, _buffer, _length);
255 if (_allocated)
256 Allocator::Free(_buffer);
257
258 // Update state
259 _buffer = newBuf;
260 _length = newLength;
261 _position = _buffer + position;
262 _allocated = true;
263 }
264
265 // Copy data
266 Platform::MemoryCopy(_position, data, bytes);
267 _position += bytes;
268}

Callers 15

UpdateMethod · 0.45
SendInPartsFunction · 0.45
GenerateMethod · 0.45
TestNetworking.cppFile · 0.45
WriteLineMethod · 0.45
WriteMethod · 0.45
SaveMethod · 0.45
CreateMethod · 0.45
CreateCubeMethod · 0.45
SaveLODMethod · 0.45
SaveMethod · 0.45
SaveMethod · 0.45

Calls 2

GetPositionFunction · 0.50
FreeFunction · 0.50

Tested by

no test coverage detected