Helper function to read data fully from a stream
| 25 | |
| 26 | // Helper function to read data fully from a stream |
| 27 | void readFully(char* buffer, int64_t bufferSize, SeekableInputStream* stream) { |
| 28 | int64_t posn = 0; |
| 29 | while (posn < bufferSize) { |
| 30 | const void* chunk; |
| 31 | int length; |
| 32 | if (!stream->Next(&chunk, &length)) { |
| 33 | throw ParseError("bad read in readFully"); |
| 34 | } |
| 35 | if (posn + length > bufferSize) { |
| 36 | throw ParseError("Corrupt dictionary blob"); |
| 37 | } |
| 38 | memcpy(buffer + posn, chunk, static_cast<size_t>(length)); |
| 39 | posn += length; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | } // namespace |
| 44 |
no test coverage detected