MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / Write

Method Write

Sources/Shared/IO/MemoryStream.cpp:110–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108 }
109
110 std::int64_t MemoryStream::Write(const void* source, std::int64_t bytesToWrite)
111 {
112 DEATH_ASSERT(source != nullptr, "source is null", 0);
113
114 std::int64_t bytesWritten = 0;
115 if (bytesToWrite > 0 && (_mode == AccessMode::Writable || _mode == AccessMode::Growable)) {
116 if (_mode == AccessMode::Growable && _size < _pos + bytesToWrite) {
117 _size = _pos + bytesToWrite;
118 arrayResize(_data, Containers::NoInit, _size);
119 }
120
121 bytesWritten = (_pos + bytesToWrite > _size ? (_size - _pos) : bytesToWrite);
122 if (bytesWritten > 0) {
123 std::memcpy(&_data[_pos], source, bytesWritten);
124 _pos += bytesWritten;
125 }
126 }
127 return bytesWritten;
128 }
129
130 bool MemoryStream::Flush()
131 {

Callers

nothing calls this directly

Calls 2

DEATH_ASSERTFunction · 0.85
arrayResizeFunction · 0.85

Tested by

no test coverage detected