| 192 | } |
| 193 | |
| 194 | void 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 | |
| 208 | void ByteBuffer::shrinkToFit() { |
| 209 | if (_capacity != _size) { |
nothing calls this directly
no test coverage detected