aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compress.c9
-rw-r--r--contrib/vstudio/vc10/zlibvc.def4
-rw-r--r--contrib/vstudio/vc11/zlibvc.def4
-rw-r--r--contrib/vstudio/vc12/zlibvc.def4
-rw-r--r--contrib/vstudio/vc14/zlibvc.def4
-rw-r--r--contrib/vstudio/vc17/zlibvc.def4
-rw-r--r--contrib/vstudio/vc9/zlibvc.def4
-rw-r--r--deflate.c31
-rw-r--r--os400/bndsrc9
-rw-r--r--os400/zlib.inc7
-rw-r--r--win32/zlib.def2
-rw-r--r--zconf.h2
-rw-r--r--zconf.h.in2
-rw-r--r--zlib.h11
-rw-r--r--zlib.map7
15 files changed, 89 insertions, 15 deletions
diff --git a/compress.c b/compress.c
index f43bacf7..0c709d06 100644
--- a/compress.c
+++ b/compress.c
@@ -69,7 +69,12 @@ int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
69 If the default memLevel or windowBits for deflateInit() is changed, then 69 If the default memLevel or windowBits for deflateInit() is changed, then
70 this function needs to be updated. 70 this function needs to be updated.
71 */ 71 */
72z_size_t ZEXPORT compressBound_z(z_size_t sourceLen) {
73 z_size_t bound = sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
74 (sourceLen >> 25) + 13;
75 return bound < sourceLen ? (z_size_t)-1 : bound;
76}
72uLong ZEXPORT compressBound(uLong sourceLen) { 77uLong ZEXPORT compressBound(uLong sourceLen) {
73 return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 78 z_size_t bound = compressBound_z(sourceLen);
74 (sourceLen >> 25) + 13; 79 return (uLong)bound != bound ? (uLong)-1 : (uLong)bound;
75} 80}
diff --git a/contrib/vstudio/vc10/zlibvc.def b/contrib/vstudio/vc10/zlibvc.def
index d5674567..e7fdebf1 100644
--- a/contrib/vstudio/vc10/zlibvc.def
+++ b/contrib/vstudio/vc10/zlibvc.def
@@ -159,3 +159,7 @@ EXPORTS
159 159
160; zlib1 v1.3.1.2 added: 160; zlib1 v1.3.1.2 added:
161 deflateUsed @179 161 deflateUsed @179
162
163; zlib1 v1.3.2 added:
164 compressBound_z @180
165 deflateBound_z @181
diff --git a/contrib/vstudio/vc11/zlibvc.def b/contrib/vstudio/vc11/zlibvc.def
index d5674567..e7fdebf1 100644
--- a/contrib/vstudio/vc11/zlibvc.def
+++ b/contrib/vstudio/vc11/zlibvc.def
@@ -159,3 +159,7 @@ EXPORTS
159 159
160; zlib1 v1.3.1.2 added: 160; zlib1 v1.3.1.2 added:
161 deflateUsed @179 161 deflateUsed @179
162
163; zlib1 v1.3.2 added:
164 compressBound_z @180
165 deflateBound_z @181
diff --git a/contrib/vstudio/vc12/zlibvc.def b/contrib/vstudio/vc12/zlibvc.def
index d5674567..e7fdebf1 100644
--- a/contrib/vstudio/vc12/zlibvc.def
+++ b/contrib/vstudio/vc12/zlibvc.def
@@ -159,3 +159,7 @@ EXPORTS
159 159
160; zlib1 v1.3.1.2 added: 160; zlib1 v1.3.1.2 added:
161 deflateUsed @179 161 deflateUsed @179
162
163; zlib1 v1.3.2 added:
164 compressBound_z @180
165 deflateBound_z @181
diff --git a/contrib/vstudio/vc14/zlibvc.def b/contrib/vstudio/vc14/zlibvc.def
index d5674567..e7fdebf1 100644
--- a/contrib/vstudio/vc14/zlibvc.def
+++ b/contrib/vstudio/vc14/zlibvc.def
@@ -159,3 +159,7 @@ EXPORTS
159 159
160; zlib1 v1.3.1.2 added: 160; zlib1 v1.3.1.2 added:
161 deflateUsed @179 161 deflateUsed @179
162
163; zlib1 v1.3.2 added:
164 compressBound_z @180
165 deflateBound_z @181
diff --git a/contrib/vstudio/vc17/zlibvc.def b/contrib/vstudio/vc17/zlibvc.def
index d5674567..e7fdebf1 100644
--- a/contrib/vstudio/vc17/zlibvc.def
+++ b/contrib/vstudio/vc17/zlibvc.def
@@ -159,3 +159,7 @@ EXPORTS
159 159
160; zlib1 v1.3.1.2 added: 160; zlib1 v1.3.1.2 added:
161 deflateUsed @179 161 deflateUsed @179
162
163; zlib1 v1.3.2 added:
164 compressBound_z @180
165 deflateBound_z @181
diff --git a/contrib/vstudio/vc9/zlibvc.def b/contrib/vstudio/vc9/zlibvc.def
index d5674567..e7fdebf1 100644
--- a/contrib/vstudio/vc9/zlibvc.def
+++ b/contrib/vstudio/vc9/zlibvc.def
@@ -159,3 +159,7 @@ EXPORTS
159 159
160; zlib1 v1.3.1.2 added: 160; zlib1 v1.3.1.2 added:
161 deflateUsed @179 161 deflateUsed @179
162
163; zlib1 v1.3.2 added:
164 compressBound_z @180
165 deflateBound_z @181
diff --git a/deflate.c b/deflate.c
index cd852669..6f886306 100644
--- a/deflate.c
+++ b/deflate.c
@@ -839,24 +839,30 @@ int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy,
839 * 839 *
840 * Shifts are used to approximate divisions, for speed. 840 * Shifts are used to approximate divisions, for speed.
841 */ 841 */
842uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) { 842z_size_t ZEXPORT deflateBound_z(z_streamp strm, z_size_t sourceLen) {
843 deflate_state *s; 843 deflate_state *s;
844 uLong fixedlen, storelen, wraplen; 844 z_size_t fixedlen, storelen, wraplen, bound;
845 845
846 /* upper bound for fixed blocks with 9-bit literals and length 255 846 /* upper bound for fixed blocks with 9-bit literals and length 255
847 (memLevel == 2, which is the lowest that may not use stored blocks) -- 847 (memLevel == 2, which is the lowest that may not use stored blocks) --
848 ~13% overhead plus a small constant */ 848 ~13% overhead plus a small constant */
849 fixedlen = sourceLen + (sourceLen >> 3) + (sourceLen >> 8) + 849 fixedlen = sourceLen + (sourceLen >> 3) + (sourceLen >> 8) +
850 (sourceLen >> 9) + 4; 850 (sourceLen >> 9) + 4;
851 if (fixedlen < sourceLen)
852 fixedlen = (z_size_t)-1;
851 853
852 /* upper bound for stored blocks with length 127 (memLevel == 1) -- 854 /* upper bound for stored blocks with length 127 (memLevel == 1) --
853 ~4% overhead plus a small constant */ 855 ~4% overhead plus a small constant */
854 storelen = sourceLen + (sourceLen >> 5) + (sourceLen >> 7) + 856 storelen = sourceLen + (sourceLen >> 5) + (sourceLen >> 7) +
855 (sourceLen >> 11) + 7; 857 (sourceLen >> 11) + 7;
858 if (storelen < sourceLen)
859 storelen = (z_size_t)-1;
856 860
857 /* if can't get parameters, return larger bound plus a wrapper */ 861 /* if can't get parameters, return larger bound plus a wrapper */
858 if (deflateStateCheck(strm)) 862 if (deflateStateCheck(strm)) {
859 return (fixedlen > storelen ? fixedlen : storelen) + 18; 863 bound = fixedlen > storelen ? fixedlen : storelen;
864 return bound + 18 < bound ? (z_size_t)-1 : bound + 18;
865 }
860 866
861 /* compute wrapper length */ 867 /* compute wrapper length */
862 s = strm->state; 868 s = strm->state;
@@ -894,14 +900,21 @@ uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
894 } 900 }
895 901
896 /* if not default parameters, return one of the conservative bounds */ 902 /* if not default parameters, return one of the conservative bounds */
897 if (s->w_bits != 15 || s->hash_bits != 8 + 7) 903 if (s->w_bits != 15 || s->hash_bits != 8 + 7) {
898 return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) + 904 bound = s->w_bits <= s->hash_bits && s->level ? fixedlen :
899 wraplen; 905 storelen;
906 return bound + wraplen < bound ? (z_size_t)-1 : bound + wraplen;
907 }
900 908
901 /* default settings: return tight bound for that case -- ~0.03% overhead 909 /* default settings: return tight bound for that case -- ~0.03% overhead
902 plus a small constant */ 910 plus a small constant */
903 return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 911 bound = sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
904 (sourceLen >> 25) + 13 - 6 + wraplen; 912 (sourceLen >> 25) + 13 - 6 + wraplen;
913 return bound < sourceLen ? (z_size_t)-1 : bound;
914}
915uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
916 z_size_t bound = deflateBound_z(strm, sourceLen);
917 return (uLong)bound != bound ? (uLong)-1 : (uLong)bound;
905} 918}
906 919
907/* ========================================================================= 920/* =========================================================================
diff --git a/os400/bndsrc b/os400/bndsrc
index 2c1c79c4..ce48ff4d 100644
--- a/os400/bndsrc
+++ b/os400/bndsrc
@@ -125,9 +125,16 @@ STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB')
125 EXPORT SYMBOL("crc32_combine_op") 125 EXPORT SYMBOL("crc32_combine_op")
126 126
127/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ 127/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
128/* Version 1.3.1.2 additional entry points. */ 128/* Version 1.3.1.2 additional entry points. */
129/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ 129/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
130 130
131 EXPORT SYMBOL("deflateUsed") 131 EXPORT SYMBOL("deflateUsed")
132 132
133/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
134/* Version 1.3.2 additional entry points. */
135/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
136
137 EXPORT SYMBOL("compressBound_z")
138 EXPORT SYMBOL("deflateBound_z")
139
133ENDPGMEXP 140ENDPGMEXP
diff --git a/os400/zlib.inc b/os400/zlib.inc
index 6805f4b9..031ff3ec 100644
--- a/os400/zlib.inc
+++ b/os400/zlib.inc
@@ -127,6 +127,9 @@
127 D compressBound PR 10U 0 extproc('compressBound') 127 D compressBound PR 10U 0 extproc('compressBound')
128 D sourceLen 10U 0 value 128 D sourceLen 10U 0 value
129 * 129 *
130 D compressBound_z PR 20U 0 extproc('compressBound')
131 D sourceLen 20U 0 value
132 *
130 D uncompress PR 10I 0 extproc('uncompress') 133 D uncompress PR 10I 0 extproc('uncompress')
131 D dest 65535 options(*varsize) Destination buffer 134 D dest 65535 options(*varsize) Destination buffer
132 D destLen 10U 0 Destination length 135 D destLen 10U 0 Destination length
@@ -366,6 +369,10 @@
366 D strm like(z_stream) Compression stream 369 D strm like(z_stream) Compression stream
367 D sourcelen 10U 0 value Compression level 370 D sourcelen 10U 0 value Compression level
368 * 371 *
372 D deflateBound_z PR 20U 0 extproc('deflateBound') Change level & strat
373 D strm like(z_stream) Compression stream
374 D sourcelen 20U 0 value Compression level
375 *
369 D deflatePending PR 10I 0 extproc('deflatePending') Change level & strat 376 D deflatePending PR 10I 0 extproc('deflatePending') Change level & strat
370 D strm like(z_stream) Compression stream 377 D strm like(z_stream) Compression stream
371 D pending 10U 0 Pending bytes 378 D pending 10U 0 Pending bytes
diff --git a/win32/zlib.def b/win32/zlib.def
index 84f6496d..dc44e7c0 100644
--- a/win32/zlib.def
+++ b/win32/zlib.def
@@ -14,6 +14,7 @@ EXPORTS
14 deflateParams 14 deflateParams
15 deflateTune 15 deflateTune
16 deflateBound 16 deflateBound
17 deflateBound_z
17 deflatePending 18 deflatePending
18 deflateUsed 19 deflateUsed
19 deflatePrime 20 deflatePrime
@@ -34,6 +35,7 @@ EXPORTS
34 compress 35 compress
35 compress2 36 compress2
36 compressBound 37 compressBound
38 compressBound_z
37 uncompress 39 uncompress
38 uncompress2 40 uncompress2
39 gzopen 41 gzopen
diff --git a/zconf.h b/zconf.h
index e4bd8089..7d936c74 100644
--- a/zconf.h
+++ b/zconf.h
@@ -34,6 +34,7 @@
34# define compress z_compress 34# define compress z_compress
35# define compress2 z_compress2 35# define compress2 z_compress2
36# define compressBound z_compressBound 36# define compressBound z_compressBound
37# define compressBound_z z_compressBound_z
37# endif 38# endif
38# define crc32 z_crc32 39# define crc32 z_crc32
39# define crc32_combine z_crc32_combine 40# define crc32_combine z_crc32_combine
@@ -44,6 +45,7 @@
44# define crc32_z z_crc32_z 45# define crc32_z z_crc32_z
45# define deflate z_deflate 46# define deflate z_deflate
46# define deflateBound z_deflateBound 47# define deflateBound z_deflateBound
48# define deflateBound_z z_deflateBound_z
47# define deflateCopy z_deflateCopy 49# define deflateCopy z_deflateCopy
48# define deflateEnd z_deflateEnd 50# define deflateEnd z_deflateEnd
49# define deflateGetDictionary z_deflateGetDictionary 51# define deflateGetDictionary z_deflateGetDictionary
diff --git a/zconf.h.in b/zconf.h.in
index e4bd8089..7d936c74 100644
--- a/zconf.h.in
+++ b/zconf.h.in
@@ -34,6 +34,7 @@
34# define compress z_compress 34# define compress z_compress
35# define compress2 z_compress2 35# define compress2 z_compress2
36# define compressBound z_compressBound 36# define compressBound z_compressBound
37# define compressBound_z z_compressBound_z
37# endif 38# endif
38# define crc32 z_crc32 39# define crc32 z_crc32
39# define crc32_combine z_crc32_combine 40# define crc32_combine z_crc32_combine
@@ -44,6 +45,7 @@
44# define crc32_z z_crc32_z 45# define crc32_z z_crc32_z
45# define deflate z_deflate 46# define deflate z_deflate
46# define deflateBound z_deflateBound 47# define deflateBound z_deflateBound
48# define deflateBound_z z_deflateBound_z
47# define deflateCopy z_deflateCopy 49# define deflateCopy z_deflateCopy
48# define deflateEnd z_deflateEnd 50# define deflateEnd z_deflateEnd
49# define deflateGetDictionary z_deflateGetDictionary 51# define deflateGetDictionary z_deflateGetDictionary
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,
diff --git a/zlib.map b/zlib.map
index 73f4fb60..e267d828 100644
--- a/zlib.map
+++ b/zlib.map
@@ -101,4 +101,9 @@ ZLIB_1.2.12 {
101 101
102ZLIB_1.3.1.2 { 102ZLIB_1.3.1.2 {
103 deflateUsed; 103 deflateUsed;
104} ZLIB_1.2.12; \ No newline at end of file 104} ZLIB_1.2.12;
105
106ZLIB_1.3.2 {
107 compressBound_z;
108 deflateBound_z;
109} ZLIB_1.3.1.2; \ No newline at end of file