Commit Graph

50 Commits

Author SHA1 Message Date
Mark Adler
e9d5486e66 Remove K&R function definitions from zlib.
C2X has removed K&R definitions from the C function syntax.
Though the standard has not yet been approved, some high-profile
compilers are now issuing warnings when such definitions are
encountered.
2023-04-15 21:17:31 -07:00
Mark Adler
02a6049eb3 Fix crash when gzsetparams() attempted for transparent write.
gzsetparams() now returns a Z_STREAM_ERROR in this case.
2022-12-26 23:38:00 -08:00
Mark Adler
84c6716a48 Minor formatting improvements.
No code changes.
2022-10-05 15:17:52 -07:00
Mark Adler
21767c654d zlib 1.2.12 2022-03-27 16:05:02 -07:00
Mark Adler
79baebe50e Avoid adding empty gzip member after gzflush with Z_FINISH. 2019-04-13 17:08:50 -07:00
Mark Adler
a577351394 Make the names in functions declarations identical to definitions. 2017-10-12 20:03:51 -07:00
Mark Adler
b25d5fcdcf Avoid undefined behaviors of memcpy() in gz*printf(). 2017-10-12 19:35:59 -07:00
Mark Adler
90287635ef Return an error if the gzputs string length can't fit in an int. 2017-02-15 22:39:26 -08:00
Mark Adler
793ad7f559 Avoid some conversion warnings in gzread.c and gzwrite.c. 2017-02-15 22:39:26 -08:00
Mark Adler
cacf7f1d4e zlib 1.2.11 2017-01-15 09:29:40 -08:00
Mark Adler
0b5c158cc7 Fix bug in gzwrite.c that produced corrupt gzip files. 2017-01-02 16:17:43 -08:00
Mark Adler
2fa463bacf zlib 1.2.9 2016-12-31 23:37:10 -08:00
Mark Adler
cca27e95cf Avoid the need for ssize_t.
Limit read() and write() requests to sizes that fit in an int.
This allows storing the return value in an int, and avoiding the
need to use or construct an ssize_t type. This is required for
Microsoft C, whose _read and _write functions take an unsigned
request and return an int.
2016-12-31 10:06:40 -08:00
Mark Adler
8f147c3d12 Avoid some random compiler warnings on various platforms. 2016-12-30 23:42:10 -08:00
Mark Adler
77bc4f8944 Add gzfwrite(), duplicating the interface of fwrite(). 2016-12-04 18:47:34 -08:00
Mark Adler
ca50ebd4df Create z_size_t and z_ssize_t types.
Normally these are set to size_t and ssize_t. But if they do not
exist, then they are set to the smallest integer type that can
contain a pointer. size_t is unsigned and ssize_t is signed.
2016-12-04 07:48:48 -08:00
Mark Adler
c5ee34c28a Don't need to emit an empty fixed block when changing parameters.
gzsetparams() was using Z_PARTIAL_FLUSH when it could use Z_BLOCK
instead. This commit uses Z_BLOCK, which avoids emitting an
unnecessary ten bits into the stream.
2016-12-04 07:48:47 -08:00
Mark Adler
123f9cfaf7 Clean up gz* function return values.
In some cases the return values did not match the documentation,
or the documentation did not document all of the return values.
gzprintf() now consistently returns negative values on error,
which matches the behavior of the stdio fprintf() function.
2016-12-04 07:48:47 -08:00
Mark Adler
1101ea79c6 Explicitly ignore a return value in gzwrite.c. 2016-12-04 07:48:47 -08:00
Mark Adler
7096424f23 Clean up type conversions. 2016-10-11 22:15:50 -07:00
Mark Adler
4f1df003ed Loop on write() calls in gzwrite.c in case of non-blocking I/O. 2016-04-05 03:09:59 -07:00
Mark Adler
c901a34c92 Avoid uninitialized access by gzclose_w(). 2015-07-28 23:13:53 -07:00
Mark Adler
95698093f0 Improve speed of gzprintf() in transparent mode. 2015-07-05 18:14:53 -07:00
Mark Adler
70252daf89 Add casts in gzwrite.c for pointer differences. 2013-04-13 18:04:06 -07:00
Mark Adler
0b16609409 zlib 1.2.7.1 2013-03-24 22:47:59 -07:00
Mark Adler
e9f0b78443 Add casts and consts to ease user conversion to C++.
You would still need to run zlib2ansi on all of the *.c files.
2013-03-24 16:09:08 -07:00
Mark Adler
b06dee4369 Add gzvprintf() as an undocumented function in zlib.
The function is only available if stdarg.h is available.
2013-03-22 18:32:37 -07:00
Mark Adler
c4888637ea Fix bug in gzclose() when gzwrite() runs out of memory.
If the deflateInit2() called for the first gzwrite() failed with a
Z_MEM_ERROR, then a subsequent gzclose() would try to free an
already freed pointer.  This fixes that.
2012-10-01 22:52:16 -07:00
Mark Adler
0cf495a1ca Fix bug where gzopen(), gzclose() would write an empty file.
A gzopen() to write (mode "w") followed immediately by a gzclose()
would output an empty zero-length file.  What it should do is write
an empty gzip file, with the gzip header, empty deflate content,
and gzip trailer totalling 20 bytes.  This fixes it to do that.
2012-09-29 22:37:55 -07:00
Mark Adler
aa566e86c4 Fix unintialized value bug in gzputc() introduced by const patches.
Avoid the use of an uninitialized value when the write buffers have
not been initialized.  A recent change to avoid the use of strm->
next_in in order to resolve some const conflicts added the use of
state->in in its place.  This patch avoids the use of state->in
when it is not initialized.  Nothing bad would actually happen,
since two variables set to the same unintialized value are
subtracted.  However valgrind was rightly complaining.  So this
fixes that.
2012-08-24 15:02:28 -07:00
Mark Adler
62d6112a79 Clean up the usage of z_const and respect const usage within zlib.
This patch allows zlib to compile cleanly with the -Wcast-qual gcc
warning enabled, but only if ZLIB_CONST is defined, which adds
const to next_in and msg in z_stream and in the in_func prototype.
A --const option is added to ./configure which adds -DZLIB_CONST
to the compile flags, and adds -Wcast-qual to the compile flags
when ZLIBGCCWARN is set in the environment.
2012-08-13 00:02:40 -07:00
Mark Adler
53bfe01cea Fix bug in gzclose_w() when gzwrite() fails to allocate memory. 2012-03-03 09:28:00 -08:00
Mark Adler
05de38d11e Cast to char * in gzprintf to avoid warnings [Zinser]. 2012-03-02 23:47:42 -08:00
Mark Adler
55b8b5fec1 Put gzflags() functionality back in zutil.c.
gzflags() was put in gzwrite.c in order to be compiled exactly the
same as gzprintf(), so that it was guaranteed to return the correct
information.  However that causes a static linkage to zlib to bring
in many routines that are often not used.  All that is required to
duplicate the compilation environment of gzprintf() is to include
gzguts.h.  So that is now done in zutil.c to assure that the correct
flags are returned.
2012-02-01 23:25:34 -08:00
Mark Adler
e75de023b6 zlib 1.2.6 2012-01-29 10:13:15 -08:00
Mark Adler
22eb01184f Have gzputc return the character written instead of the argument.
When successful, gzputc would return the second argument.  If the
second argument were -1, gzputc would return -1 instead of the
character written, which was 255.  However the -1 would not be
distinguishable from an error.  Now gzputc returns 255 in that
case.
2012-01-29 09:47:29 -08:00
Mark Adler
850a198ff1 Avoid use of Z_BUF_ERROR in gz* functions except for premature EOF.
Z_BUF_ERROR was also being used for an unsuccessful gzungetc and for buffer
lengths that didn't fit in an int.  Those uses were changed to Z_DATA_ERROR
in order to assure that Z_BUF_ERROR occurs only when a premature end of
input occurs, indicating that gzclearerr() can be used.
2011-12-13 22:29:37 -08:00
Mark Adler
fb00fda903 Fix gzwrite.c to accommodate reduced memory zlib compilation.
gzwrite.c had hard-coded parameters to deflateInit2() which could
contradict compile-time options for the use of less memory and fewer
code bits.  This patch suggested by Karsten Saunte fixes that.
2011-12-10 22:33:17 -08:00
Mark Adler
26a99cd895 Add a transparent write mode to gzopen() when 'T' is in the mode. 2011-10-02 13:34:29 -07:00
Mark Adler
00c836e325 Merge vestigial vsnprintf determination from zutil.h to gzguts.h.
This also moves some of the same from zconf.h to gzguts.h. A new
function, gzflags(), was created to pass the compilation flags
related to vsnprintf usage back to zlibCompileFlags() in zutil.c.
In the process, various compiler configuration files were updated
to include gzflags(), as well as the new gzgetc_() function added
when the gzgetc() macro was introduced in a previous patch.
2011-10-02 11:15:00 -07:00
Mark Adler
8768ba98af Fix gzclose() to return the actual error last encountered. 2011-09-30 22:19:12 -07:00
Mark Adler
acfc85772a Change gzgetc() to a macro for speed (~40% speedup in testing). 2011-09-26 22:50:28 -07:00
Mark Adler
10daf0d4d7 zlib 1.2.5.1 2011-09-11 11:04:49 -07:00
Mark Adler
59ca2179ff zlib 1.2.4-pre2 2011-09-09 23:33:23 -07:00
Mark Adler
67cc20d004 zlib 1.2.4-pre1 2011-09-09 23:32:36 -07:00
Mark Adler
7751bd4c71 zlib 1.2.3.9 2011-09-09 23:27:26 -07:00
Mark Adler
e0ff940e1a zlib 1.2.3.8 2011-09-09 23:27:17 -07:00
Mark Adler
7df877eccd zlib 1.2.3.7 2011-09-09 23:27:08 -07:00
Mark Adler
dc5a43ebfa zlib 1.2.3.6 2011-09-09 23:26:58 -07:00
Mark Adler
d004b04783 zlib 1.2.3.5 2011-09-09 23:26:49 -07:00