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

Function gzclose_w

freebsd/contrib/zstd/zlibWrapper/gzwrite.c:633–671  ·  view source on GitHub ↗

-- see zlib.h -- */

(file)

Source from the content-addressed store, hash-verified

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

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