=========================================================================== * Test inflate() with small buffers */
(compr, comprLen, uncompr, uncomprLen)
| 261 | * Test inflate() with small buffers |
| 262 | */ |
| 263 | void test_inflate(compr, comprLen, uncompr, uncomprLen) |
| 264 | Byte *compr, *uncompr; |
| 265 | uLong comprLen, uncomprLen; |
| 266 | { |
| 267 | int err; |
| 268 | z_stream d_stream; /* decompression stream */ |
| 269 | |
| 270 | strcpy((char*)uncompr, "garbage"); |
| 271 | |
| 272 | d_stream.zalloc = zalloc; |
| 273 | d_stream.zfree = zfree; |
| 274 | d_stream.opaque = (voidpf)0; |
| 275 | |
| 276 | d_stream.next_in = compr; |
| 277 | d_stream.avail_in = 0; |
| 278 | d_stream.next_out = uncompr; |
| 279 | |
| 280 | err = inflateInit(&d_stream); |
| 281 | CHECK_ERR(err, "inflateInit"); |
| 282 | |
| 283 | while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) { |
| 284 | d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */ |
| 285 | err = inflate(&d_stream, Z_NO_FLUSH); |
| 286 | if (err == Z_STREAM_END) break; |
| 287 | CHECK_ERR(err, "inflate"); |
| 288 | } |
| 289 | |
| 290 | err = inflateEnd(&d_stream); |
| 291 | CHECK_ERR(err, "inflateEnd"); |
| 292 | |
| 293 | if (strcmp((char*)uncompr, hello)) { |
| 294 | fprintf(stderr, "bad inflate\n"); |
| 295 | exit(1); |
| 296 | } else { |
| 297 | printf("inflate(): %s\n", (char *)uncompr); |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | /* =========================================================================== |
| 302 | * Test deflate() with large buffers and dynamic change of compression level |