-- see zlib.h -- */
| 575 | |
| 576 | /* -- see zlib.h -- */ |
| 577 | int ZEXPORT gzclose_r(gzFile file) { |
| 578 | int ret, err; |
| 579 | gz_statep state; |
| 580 | |
| 581 | /* get internal structure */ |
| 582 | if (file == NULL) |
| 583 | return Z_STREAM_ERROR; |
| 584 | state = (gz_statep)file; |
| 585 | |
| 586 | /* check that we're reading */ |
| 587 | if (state->mode != GZ_READ) |
| 588 | return Z_STREAM_ERROR; |
| 589 | |
| 590 | /* free memory and close file */ |
| 591 | if (state->size) { |
| 592 | inflateEnd(&(state->strm)); |
| 593 | free(state->out); |
| 594 | free(state->in); |
| 595 | } |
| 596 | err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK; |
| 597 | gz_error(state, Z_OK, NULL); |
| 598 | free(state->path); |
| 599 | ret = close(state->fd); |
| 600 | free(state); |
| 601 | return ret ? Z_ERRNO : err; |
| 602 | } |