aboutsummaryrefslogtreecommitdiff
path: root/zlib.h
diff options
context:
space:
mode:
authorMark Adler <git@madler.net>2026-01-04 10:34:44 -0600
committerMark Adler <git@madler.net>2026-01-05 15:03:04 -0600
commit916dc1ac351795c9bf86a3d19c3667b014b9d28e (patch)
tree08efd9aa0c5387fe80c1ce15a9fdb0ca8e29c01c /zlib.h
parentfd366384cf324d750596feb03be44ddf4d1e6acd (diff)
downloadzlib-916dc1ac351795c9bf86a3d19c3667b014b9d28e.tar.gz
zlib-916dc1ac351795c9bf86a3d19c3667b014b9d28e.tar.bz2
zlib-916dc1ac351795c9bf86a3d19c3667b014b9d28e.zip
Add compressBound_z and deflateBound_z functions for large values.
These take and return size_t integers, instead of unsigned longs, for those platforms with 32-bit longs. This commit also assures that overflows of either integer type results in the maximum value for that type, instead of wrapping to small values.
Diffstat (limited to 'zlib.h')
-rw-r--r--zlib.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/zlib.h b/zlib.h
index 595e3cfd..5567bcc3 100644
--- a/zlib.h
+++ b/zlib.h
@@ -765,8 +765,8 @@ ZEXTERN int ZEXPORT deflateTune(z_streamp strm,
765 returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. 765 returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
766 */ 766 */
767 767
768ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, 768ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen);
769 uLong sourceLen); 769ZEXTERN z_size_t ZEXPORT deflateBound_z(z_streamp strm, z_size_t sourceLen);
770/* 770/*
771 deflateBound() returns an upper bound on the compressed size after 771 deflateBound() returns an upper bound on the compressed size after
772 deflation of sourceLen bytes. It must be called after deflateInit() or 772 deflation of sourceLen bytes. It must be called after deflateInit() or
@@ -778,6 +778,9 @@ ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm,
778 to return Z_STREAM_END. Note that it is possible for the compressed size to 778 to return Z_STREAM_END. Note that it is possible for the compressed size to
779 be larger than the value returned by deflateBound() if flush options other 779 be larger than the value returned by deflateBound() if flush options other
780 than Z_FINISH or Z_NO_FLUSH are used. 780 than Z_FINISH or Z_NO_FLUSH are used.
781
782 delfateBound_z() is the same, but takes and returns a size_t length for
783 those systems on which a long is 32 bits.
781*/ 784*/
782 785
783ZEXTERN int ZEXPORT deflatePending(z_streamp strm, 786ZEXTERN int ZEXPORT deflatePending(z_streamp strm,
@@ -1293,10 +1296,14 @@ ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen,
1293*/ 1296*/
1294 1297
1295ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen); 1298ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen);
1299ZEXTERN z_size_t ZEXPORT compressBound_z(z_size_t sourceLen);
1296/* 1300/*
1297 compressBound() returns an upper bound on the compressed size after 1301 compressBound() returns an upper bound on the compressed size after
1298 compress() or compress2() on sourceLen bytes. It would be used before a 1302 compress() or compress2() on sourceLen bytes. It would be used before a
1299 compress() or compress2() call to allocate the destination buffer. 1303 compress() or compress2() call to allocate the destination buffer.
1304
1305 compressBound_z() is the same, but takes and returns a size_t length for
1306 those systems on which a long is 32 bits.
1300*/ 1307*/
1301 1308
1302ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, 1309ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen,