MCPcopy Create free account
hub / github.com/F-Stack/f-stack / gzclose_w

Function gzclose_w

freebsd/contrib/zlib/gzwrite.c:630–668  ·  view source on GitHub ↗

-- see zlib.h -- */

(file)

Source from the content-addressed store, hash-verified

628
629/* -- see zlib.h -- */
630int ZEXPORT gzclose_w(file)
631 gzFile file;
632{
633 int ret = Z_OK;
634 gz_statep state;
635
636 /* get internal structure */
637 if (file == NULL)
638 return Z_STREAM_ERROR;
639 state = (gz_statep)file;
640
641 /* check that we're writing */
642 if (state->mode != GZ_WRITE)
643 return Z_STREAM_ERROR;
644
645 /* check for seek request */
646 if (state->seek) {
647 state->seek = 0;
648 if (gz_zero(state, state->skip) == -1)
649 ret = state->err;
650 }
651
652 /* flush, free memory, and close file */
653 if (gz_comp(state, Z_FINISH) == -1)
654 ret = state->err;
655 if (state->size) {
656 if (!state->direct) {
657 (void)deflateEnd(&(state->strm));
658 free(state->out);
659 }
660 free(state->in);
661 }
662 gz_error(state, Z_OK, NULL);
663 free(state->path);
664 if (close(state->fd) == -1)
665 ret = Z_ERRNO;
666 free(state);
667 return ret;
668}

Callers 1

gzcloseFunction · 0.70

Calls 6

deflateEndFunction · 0.85
gz_zeroFunction · 0.70
gz_compFunction · 0.70
gz_errorFunction · 0.70
freeFunction · 0.50
closeFunction · 0.50

Tested by

no test coverage detected