MCPcopy Create free account
hub / github.com/Icinga/icinga2 / FillFromStream

Method FillFromStream

lib/base/stream.cpp:112–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112bool StreamReadContext::FillFromStream(const Stream::Ptr& stream, bool may_wait)
113{
114 if (may_wait && stream->SupportsWaiting())
115 stream->WaitForData();
116
117 size_t count = 0;
118
119 do {
120 Buffer = (char *)realloc(Buffer, Size + 4096);
121
122 if (!Buffer)
123 throw std::bad_alloc();
124
125 if (stream->IsEof())
126 break;
127
128 size_t rc = stream->Read(Buffer + Size, 4096);
129
130 Size += rc;
131 count += rc;
132 } while (count < 64 * 1024 && stream->IsDataAvailable());
133
134 if (count == 0 && stream->IsEof())
135 return false;
136 else
137 return true;
138}
139
140void StreamReadContext::DropData(size_t count)
141{

Callers 2

ReadLineMethod · 0.80
ReadStringFromStreamMethod · 0.80

Calls 5

WaitForDataMethod · 0.80
SupportsWaitingMethod · 0.45
IsEofMethod · 0.45
ReadMethod · 0.45
IsDataAvailableMethod · 0.45

Tested by

no test coverage detected