Fills up the input buffer. Should not be called if there are at least 36 bytes present after current position. After encountering the end of the input stream, 64 additional zero bytes are copied to the buffer.
(State s)
| 58 | * buffer. |
| 59 | */ |
| 60 | static int readMoreInput(State s) { |
| 61 | if (s.endOfStreamReached != 0) { |
| 62 | if (halfAvailable(s) >= -2) { |
| 63 | return BROTLI_OK; |
| 64 | } |
| 65 | return Utils.makeError(s, BROTLI_ERROR_TRUNCATED_INPUT); |
| 66 | } |
| 67 | final int readOffset = s.halfOffset << LOG_HALF_SIZE; |
| 68 | int bytesInBuffer = CAPACITY - readOffset; |
| 69 | // Move unused bytes to the head of the buffer. |
| 70 | Utils.copyBytesWithin(s.byteBuffer, 0, readOffset, CAPACITY); |
| 71 | s.halfOffset = 0; |
| 72 | while (bytesInBuffer < CAPACITY) { |
| 73 | final int spaceLeft = CAPACITY - bytesInBuffer; |
| 74 | final int len = Utils.readInput(s, s.byteBuffer, bytesInBuffer, spaceLeft); |
| 75 | if (len < BROTLI_ERROR) { |
| 76 | return len; |
| 77 | } |
| 78 | // EOF is -1 in Java, but 0 in C#. |
| 79 | if (len <= 0) { |
| 80 | s.endOfStreamReached = 1; |
| 81 | s.tailBytes = bytesInBuffer; |
| 82 | bytesInBuffer += HALF_SIZE - 1; |
| 83 | break; |
| 84 | } |
| 85 | bytesInBuffer += len; |
| 86 | } |
| 87 | bytesToNibbles(s, bytesInBuffer); |
| 88 | return BROTLI_OK; |
| 89 | } |
| 90 | |
| 91 | static int checkHealth(State s, int endOfStream) { |
| 92 | if (s.endOfStreamReached == 0) { |
no test coverage detected