MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / gzclose_w

Function gzclose_w

extern/zlib/src/gzwrite.c:595–631  ·  view source on GitHub ↗

-- see zlib.h -- */

Source from the content-addressed store, hash-verified

593
594/* -- see zlib.h -- */
595int ZEXPORT gzclose_w(gzFile file) {
596 int ret = Z_OK;
597 gz_statep state;
598
599 /* get internal structure */
600 if (file == NULL)
601 return Z_STREAM_ERROR;
602 state = (gz_statep)file;
603
604 /* check that we're writing */
605 if (state->mode != GZ_WRITE)
606 return Z_STREAM_ERROR;
607
608 /* check for seek request */
609 if (state->seek) {
610 state->seek = 0;
611 if (gz_zero(state, state->skip) == -1)
612 ret = state->err;
613 }
614
615 /* flush, free memory, and close file */
616 if (gz_comp(state, Z_FINISH) == -1)
617 ret = state->err;
618 if (state->size) {
619 if (!state->direct) {
620 (void)deflateEnd(&(state->strm));
621 free(state->out);
622 }
623 free(state->in);
624 }
625 gz_error(state, Z_OK, NULL);
626 free(state->path);
627 if (close(state->fd) == -1)
628 ret = Z_ERRNO;
629 free(state);
630 return ret;
631}

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