MCPcopy Create free account
hub / github.com/MariaDB/server / gzclose_w

Function gzclose_w

zlib/gzwrite.c:667–700  ·  view source on GitHub ↗

-- see zlib.h -- */

Source from the content-addressed store, hash-verified

665
666/* -- see zlib.h -- */
667int ZEXPORT gzclose_w(gzFile file) {
668 int ret = Z_OK;
669 gz_statep state;
670
671 /* get internal structure */
672 if (file == NULL)
673 return Z_STREAM_ERROR;
674 state = (gz_statep)file;
675
676 /* check that we're writing */
677 if (state->mode != GZ_WRITE)
678 return Z_STREAM_ERROR;
679
680 /* check for seek request */
681 if (state->skip && gz_zero(state) == -1)
682 ret = state->err;
683
684 /* flush, free memory, and close file */
685 if (gz_comp(state, Z_FINISH) == -1)
686 ret = state->err;
687 if (state->size) {
688 if (!state->direct) {
689 (void)deflateEnd(&(state->strm));
690 free(state->out);
691 }
692 free(state->in);
693 }
694 gz_error(state, Z_OK, NULL);
695 free(state->path);
696 if (close(state->fd) == -1)
697 ret = Z_ERRNO;
698 free(state);
699 return ret;
700}

Callers 1

gzcloseFunction · 0.85

Calls 5

gz_zeroFunction · 0.85
gz_compFunction · 0.85
deflateEndFunction · 0.85
freeFunction · 0.85
gz_errorFunction · 0.85

Tested by

no test coverage detected