-- see zlib.h -- */
| 593 | |
| 594 | /* -- see zlib.h -- */ |
| 595 | int ZEXPORT gzclose_w(gzFile file) { |
| 596 | int ret = Z_OK; |
| 597 | gz_statep state; |
| 598 | |
| 599 | /* get internal structure */ |
| 600 | if (file == NULL) |
| 601 | return Z_STREAM_ERROR; |
| 602 | state = (gz_statep)file; |
| 603 | |
| 604 | /* check that we're writing */ |
| 605 | if (state->mode != GZ_WRITE) |
| 606 | return Z_STREAM_ERROR; |
| 607 | |
| 608 | /* check for seek request */ |
| 609 | if (state->seek) { |
| 610 | state->seek = 0; |
| 611 | if (gz_zero(state, state->skip) == -1) |
| 612 | ret = state->err; |
| 613 | } |
| 614 | |
| 615 | /* flush, free memory, and close file */ |
| 616 | if (gz_comp(state, Z_FINISH) == -1) |
| 617 | ret = state->err; |
| 618 | if (state->size) { |
| 619 | if (!state->direct) { |
| 620 | (void)deflateEnd(&(state->strm)); |
| 621 | free(state->out); |
| 622 | } |
| 623 | free(state->in); |
| 624 | } |
| 625 | gz_error(state, Z_OK, NULL); |
| 626 | free(state->path); |
| 627 | if (close(state->fd) == -1) |
| 628 | ret = Z_ERRNO; |
| 629 | free(state); |
| 630 | return ret; |
| 631 | } |
no test coverage detected