[ntcore] Fix write_impl (#5847)

The previous fix didn't handle all cases correctly. Instead, add a new
function to raw_ostream (SetNumBytesInBuffer) to allow always using the
full buffer size, and revamp write_impl to more cleanly handle all
cases.
This commit is contained in:
Peter Johnson
2023-10-30 08:23:33 -07:00
committed by GitHub
parent 1713386869
commit 07e13d60a2
4 changed files with 63 additions and 26 deletions

View File

@@ -356,6 +356,11 @@ protected:
SetBufferAndMode(BufferStart, Size, BufferKind::ExternalBuffer);
}
/// Force-set the number of bytes in the raw_ostream buffer.
void SetNumBytesInBuffer(size_t Size) {
OutBufCur = OutBufStart + Size;
}
/// Return an efficient buffer size for the underlying output mechanism.
virtual size_t preferred_buffer_size() const;