=========================================================================== * Cleanup then free the given gz_stream. Return a zlib error code. Try freeing in the reverse order of allocations. */
(s)
| 358 | Try freeing in the reverse order of allocations. |
| 359 | */ |
| 360 | local int destroy (s) |
| 361 | gz_stream *s; |
| 362 | { |
| 363 | int err = Z_OK; |
| 364 | |
| 365 | if (!s) return Z_STREAM_ERROR; |
| 366 | |
| 367 | TRYFREE(s->msg); |
| 368 | |
| 369 | if (s->stream.state != NULL) { |
| 370 | if (s->mode == 'w') { |
| 371 | #ifdef NO_GZCOMPRESS |
| 372 | err = Z_STREAM_ERROR; |
| 373 | #else |
| 374 | err = deflateEnd(&(s->stream)); |
| 375 | #endif |
| 376 | } else if (s->mode == 'r') { |
| 377 | err = inflateEnd(&(s->stream)); |
| 378 | } |
| 379 | } |
| 380 | if (s->file != NULL && fclose(s->file)) { |
| 381 | #ifdef ESPIPE |
| 382 | if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ |
| 383 | #endif |
| 384 | err = Z_ERRNO; |
| 385 | } |
| 386 | if (s->z_err < 0) err = s->z_err; |
| 387 | |
| 388 | TRYFREE(s->inbuf); |
| 389 | TRYFREE(s->outbuf); |
| 390 | TRYFREE(s->path); |
| 391 | TRYFREE(s); |
| 392 | return err; |
| 393 | } |
| 394 | |
| 395 | /* =========================================================================== |
| 396 | Reads the given number of uncompressed bytes from the compressed file. |
no test coverage detected