1 //===- circular_raw_ostream.cpp - Implement circular_raw_ostream ----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This implements support for circular buffered streams.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Support/circular_raw_ostream.h"
18 void circular_raw_ostream::write_impl(const char *Ptr
, size_t Size
) {
19 if (BufferSize
== 0) {
20 TheStream
->write(Ptr
, Size
);
24 // Write into the buffer, wrapping if necessary.
27 std::min(unsigned(Size
), unsigned(BufferSize
- (Cur
- BufferArray
)));
28 memcpy(Cur
, Ptr
, Bytes
);
31 if (Cur
== BufferArray
+ BufferSize
) {
32 // Reset the output pointer to the start of the buffer.
39 void circular_raw_ostream::flushBufferWithBanner() {
40 if (BufferSize
!= 0) {
41 // Write out the buffer
42 TheStream
->write(Banner
, std::strlen(Banner
));