blob: 12a2dfc58953d8c281baf4af9b001acadccc6efe [file] [log] [blame]
Przemyslaw Skibinskif0d7da72016-11-29 18:02:34 +01001/* gzclose.c contains minimal changes required to be compiled with zlibWrapper:
2 * - gz_statep was converted to union to work with -Wstrict-aliasing=1 */
3
Przemyslaw Skibinski3bf9a722016-11-24 18:26:30 +01004/* gzclose.c -- zlib gzclose() function
5 * Copyright (C) 2004, 2010 Mark Adler
Danielle Rozenblit4dffc352022-12-14 06:58:35 -08006 * For conditions of distribution and use, see https://www.zlib.net/zlib_license.html
Przemyslaw Skibinski3bf9a722016-11-24 18:26:30 +01007 */
8
9#include "gzguts.h"
10
11/* gzclose() is in a separate file so that it is linked in only if it is used.
12 That way the other gzclose functions can be used instead to avoid linking in
13 unneeded compression or decompression routines. */
Ed Maste2ce02902023-12-13 19:54:29 -050014int ZEXPORT gzclose(gzFile file) {
Przemyslaw Skibinski3bf9a722016-11-24 18:26:30 +010015#ifndef NO_GZCOMPRESS
16 gz_statep state;
17
18 if (file == NULL)
19 return Z_STREAM_ERROR;
Yann Colletcb18fff2019-09-24 17:50:58 -070020 state.file = file;
Przemyslaw Skibinski3bf9a722016-11-24 18:26:30 +010021
Przemyslaw Skibinskia1f60632016-11-29 15:50:28 +010022 return state.state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file);
Przemyslaw Skibinski3bf9a722016-11-24 18:26:30 +010023#else
24 return gzclose_r(file);
25#endif
26}