MCPcopy Create free account
hub / github.com/Snapchat/Valdi / reallocate

Method reallocate

valdi_core/src/valdi_core/cpp/Utils/ByteBuffer.cpp:194–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194void ByteBuffer::reallocate(size_t capacity) {
195 auto* newData = allocateBuffer(capacity);
196
197 auto* oldData = _data;
198
199 if (newData != nullptr && oldData != nullptr) {
200 std::memcpy(newData, oldData, std::min(_capacity, capacity));
201 }
202 deallocateBuffer(oldData);
203
204 _capacity = capacity;
205 _data = newData;
206}
207
208void ByteBuffer::shrinkToFit() {
209 if (_capacity != _size) {

Callers

nothing calls this directly

Calls 3

allocateBufferFunction · 0.85
minFunction · 0.85
deallocateBufferFunction · 0.85

Tested by

no test coverage detected