-- see zlib.h -- */
(file)
| 649 | |
| 650 | /* -- see zlib.h -- */ |
| 651 | int ZEXPORT gzclose_r(file) |
| 652 | gzFile file; |
| 653 | { |
| 654 | int ret, err; |
| 655 | gz_statep state; |
| 656 | |
| 657 | /* get internal structure */ |
| 658 | if (file == NULL) |
| 659 | return Z_STREAM_ERROR; |
| 660 | state.file = file; |
| 661 | |
| 662 | /* check that we're reading */ |
| 663 | if (state.state->mode != GZ_READ) |
| 664 | return Z_STREAM_ERROR; |
| 665 | |
| 666 | /* free memory and close file */ |
| 667 | if (state.state->size) { |
| 668 | inflateEnd(&(state.state->strm)); |
| 669 | free(state.state->out); |
| 670 | free(state.state->in); |
| 671 | } |
| 672 | err = state.state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK; |
| 673 | gz_error(state, Z_OK, NULL); |
| 674 | free(state.state->path); |
| 675 | ret = close(state.state->fd); |
| 676 | free(state.state); |
| 677 | return ret ? Z_ERRNO : err; |
| 678 | } |