=========================================================================== * Read a new buffer from the current input stream, update the adler32 * and total number of bytes read. All deflate() input goes through * this function so some applications may wish to modify it to avoid * allocating a large strm->next_in buffer and copying from it. * (See also flush_pending()). */
| 216 | * (See also flush_pending()). |
| 217 | */ |
| 218 | local unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size) { |
| 219 | unsigned len = strm->avail_in; |
| 220 | |
| 221 | if (len > size) len = size; |
| 222 | if (len == 0) return 0; |
| 223 | |
| 224 | strm->avail_in -= len; |
| 225 | |
| 226 | zmemcpy(buf, strm->next_in, len); |
| 227 | if (strm->state->wrap == 1) { |
| 228 | strm->adler = adler32(strm->adler, buf, len); |
| 229 | } |
| 230 | #ifdef GZIP |
| 231 | else if (strm->state->wrap == 2) { |
| 232 | strm->adler = crc32(strm->adler, buf, len); |
| 233 | } |
| 234 | #endif |
| 235 | strm->next_in += len; |
| 236 | strm->total_in += len; |
| 237 | |
| 238 | return len; |
| 239 | } |
| 240 | |
| 241 | /* =========================================================================== |
| 242 | * Fill the window when the lookahead becomes insufficient. |
no test coverage detected