| 110 | } |
| 111 | |
| 112 | bool 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 | |
| 140 | void StreamReadContext::DropData(size_t count) |
| 141 | { |
no test coverage detected