-- see zlib.h -- */
(file)
| 671 | |
| 672 | /* -- see zlib.h -- */ |
| 673 | int ZEXPORT gzclose_w(file) |
| 674 | |
| 675 | gzFile file; |
| 676 | { |
| 677 | int ret = Z_OK; |
| 678 | gz_statep state; |
| 679 | |
| 680 | /* get internal structure */ |
| 681 | if (file == NULL) |
| 682 | return Z_STREAM_ERROR; |
| 683 | state = (gz_statep)file; |
| 684 | |
| 685 | /* check that we're writing */ |
| 686 | if (state->mode != GZ_WRITE) |
| 687 | return Z_STREAM_ERROR; |
| 688 | |
| 689 | /* check for seek request */ |
| 690 | if (state->seek) |
| 691 | { |
| 692 | state->seek = 0; |
| 693 | if (gz_zero(state, state->skip) == -1) |
| 694 | ret = state->err; |
| 695 | } |
| 696 | |
| 697 | /* flush, free memory, and close file */ |
| 698 | if (gz_comp(state, Z_FINISH) == -1) |
| 699 | ret = state->err; |
| 700 | if (state->size) |
| 701 | { |
| 702 | if (!state->direct) |
| 703 | { |
| 704 | (void)deflateEnd(&(state->strm)); |
| 705 | free(state->out); |
| 706 | } |
| 707 | free(state->in); |
| 708 | } |
| 709 | gz_error(state, Z_OK, NULL); |
| 710 | free(state->path); |
| 711 | if (close(state->fd) == -1) |
| 712 | ret = Z_ERRNO; |
| 713 | free(state); |
| 714 | return ret; |
| 715 | } |
no test coverage detected