=========================================================================== * Test inflate() with small buffers */
(compr, comprLen, uncompr, uncomprLen)
| 236 | * Test inflate() with small buffers |
| 237 | */ |
| 238 | void test_inflate(compr, comprLen, uncompr, uncomprLen) |
| 239 | Byte *compr, *uncompr; |
| 240 | uLong comprLen, uncomprLen; |
| 241 | { |
| 242 | int err; |
| 243 | z_stream d_stream; /* decompression stream */ |
| 244 | |
| 245 | strcpy((char*)uncompr, "garbage"); |
| 246 | |
| 247 | d_stream.zalloc = zalloc; |
| 248 | d_stream.zfree = zfree; |
| 249 | d_stream.opaque = (voidpf)0; |
| 250 | |
| 251 | d_stream.next_in = compr; |
| 252 | d_stream.avail_in = 0; |
| 253 | d_stream.next_out = uncompr; |
| 254 | |
| 255 | err = inflateInit(&d_stream); |
| 256 | CHECK_ERR(err, "inflateInit"); |
| 257 | |
| 258 | while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) { |
| 259 | d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */ |
| 260 | err = inflate(&d_stream, Z_NO_FLUSH); |
| 261 | if (err == Z_STREAM_END) break; |
| 262 | CHECK_ERR(err, "inflate"); |
| 263 | } |
| 264 | |
| 265 | err = inflateEnd(&d_stream); |
| 266 | CHECK_ERR(err, "inflateEnd"); |
| 267 | |
| 268 | if (strcmp((char*)uncompr, hello)) { |
| 269 | fprintf(stderr, "bad inflate\n"); |
| 270 | exit(1); |
| 271 | } else { |
| 272 | printf("inflate(): %s\n", (char *)uncompr); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | /* =========================================================================== |
| 277 | * Test deflate() with large buffers and dynamic change of compression level |