MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / gzclose_w

Function gzclose_w

extlibs/minizip/src/gzwrite.c:673–715  ·  view source on GitHub ↗

-- see zlib.h -- */

(file)

Source from the content-addressed store, hash-verified

671
672/* -- see zlib.h -- */
673int ZEXPORT gzclose_w(file)
674
675gzFile 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}

Callers 1

gzcloseFunction · 0.85

Calls 4

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

Tested by

no test coverage detected