| 55 | */ |
| 56 | template <class Derived, typename C, class Allocator> |
| 57 | typename OutputStreamBufferBase<Derived, C, Allocator>::int_type |
| 58 | OutputStreamBufferBase<Derived, C, Allocator>::overflow(int_type c) { |
| 59 | if (this->pptr() >= this->epptr()) { |
| 60 | if (mStorageSize >= kMaxBufferSize) |
| 61 | return traits_type::eof(); |
| 62 | |
| 63 | uint32_t newStorageSize = mStorageSize * 2; |
| 64 | C* newStorage = mAllocator.allocate(newStorageSize + 1); |
| 65 | std::copy(mStorage, mStorage + mStorageSize, newStorage); |
| 66 | mAllocator.deallocate(mStorage, mStorageSize + 1); |
| 67 | mStorage = newStorage; |
| 68 | |
| 69 | madlib_assert( |
| 70 | this->pptr() == this->epptr() && |
| 71 | this->pptr() - this->pbase() == static_cast<int64_t>(mStorageSize), |
| 72 | std::logic_error("Internal error: Logging buffer has become " |
| 73 | "inconsistent")); |
| 74 | |
| 75 | this->setp(mStorage, mStorage + newStorageSize); |
| 76 | this->pbump(mStorageSize); |
| 77 | mStorageSize = newStorageSize; |
| 78 | } else if (c == traits_type::eof()) |
| 79 | return traits_type::eof(); |
| 80 | |
| 81 | *this->pptr() = static_cast<C>(c); |
| 82 | this->pbump(1); |
| 83 | return traits_type::not_eof(c); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * @brief Flush and reset buffer. |
nothing calls this directly
no test coverage detected