=========================================================================== * Test inflate() with large buffers */
(compr, comprLen, uncompr, uncomprLen)
| 332 | * Test inflate() with large buffers |
| 333 | */ |
| 334 | void test_large_inflate(compr, comprLen, uncompr, uncomprLen) |
| 335 | Byte *compr, *uncompr; |
| 336 | uLong comprLen, uncomprLen; |
| 337 | { |
| 338 | int err; |
| 339 | z_stream d_stream; /* decompression stream */ |
| 340 | |
| 341 | strcpy((char*)uncompr, "garbage"); |
| 342 | |
| 343 | d_stream.zalloc = zalloc; |
| 344 | d_stream.zfree = zfree; |
| 345 | d_stream.opaque = (voidpf)0; |
| 346 | |
| 347 | d_stream.next_in = compr; |
| 348 | d_stream.avail_in = (uInt)comprLen; |
| 349 | |
| 350 | err = inflateInit(&d_stream); |
| 351 | CHECK_ERR(err, "inflateInit"); |
| 352 | |
| 353 | for (;;) { |
| 354 | d_stream.next_out = uncompr; /* discard the output */ |
| 355 | d_stream.avail_out = (uInt)uncomprLen; |
| 356 | err = inflate(&d_stream, Z_NO_FLUSH); |
| 357 | if (err == Z_STREAM_END) break; |
| 358 | CHECK_ERR(err, "large inflate"); |
| 359 | } |
| 360 | |
| 361 | err = inflateEnd(&d_stream); |
| 362 | CHECK_ERR(err, "inflateEnd"); |
| 363 | |
| 364 | if (d_stream.total_out != 2*uncomprLen + comprLen/2) { |
| 365 | fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out); |
| 366 | exit(1); |
| 367 | } else { |
| 368 | printf("large_inflate(): OK\n"); |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | /* =========================================================================== |
| 373 | * Test deflate() with full flush |