MCPcopy Create free account
hub / github.com/apache/madlib / overflow

Method overflow

src/dbal/OutputStreamBufferBase_impl.hpp:57–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55 */
56template <class Derived, typename C, class Allocator>
57typename OutputStreamBufferBase<Derived, C, Allocator>::int_type
58OutputStreamBufferBase<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.

Callers

nothing calls this directly

Calls 2

deallocateMethod · 0.80
allocateMethod · 0.45

Tested by

no test coverage detected