comparison zlib/compress.c @ 2690:9ef72ee5c0b0

Update vendored zlib to 1.3.1
author Michael Pavone <pavone@retrodev.com>
date Sun, 15 Jun 2025 15:39:33 -0700
parents 00d788dac91a
children
comparison
equal deleted inserted replaced
2689:bd6e33de0972 2690:9ef72ee5c0b0
17 17
18 compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 18 compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
19 memory, Z_BUF_ERROR if there was not enough room in the output buffer, 19 memory, Z_BUF_ERROR if there was not enough room in the output buffer,
20 Z_STREAM_ERROR if the level parameter is invalid. 20 Z_STREAM_ERROR if the level parameter is invalid.
21 */ 21 */
22 int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) 22 int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
23 Bytef *dest; 23 uLong sourceLen, int level) {
24 uLongf *destLen;
25 const Bytef *source;
26 uLong sourceLen;
27 int level;
28 {
29 z_stream stream; 24 z_stream stream;
30 int err; 25 int err;
31 const uInt max = (uInt)-1; 26 const uInt max = (uInt)-1;
32 uLong left; 27 uLong left;
33 28
63 return err == Z_STREAM_END ? Z_OK : err; 58 return err == Z_STREAM_END ? Z_OK : err;
64 } 59 }
65 60
66 /* =========================================================================== 61 /* ===========================================================================
67 */ 62 */
68 int ZEXPORT compress (dest, destLen, source, sourceLen) 63 int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
69 Bytef *dest; 64 uLong sourceLen) {
70 uLongf *destLen;
71 const Bytef *source;
72 uLong sourceLen;
73 {
74 return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 65 return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
75 } 66 }
76 67
77 /* =========================================================================== 68 /* ===========================================================================
78 If the default memLevel or windowBits for deflateInit() is changed, then 69 If the default memLevel or windowBits for deflateInit() is changed, then
79 this function needs to be updated. 70 this function needs to be updated.
80 */ 71 */
81 uLong ZEXPORT compressBound (sourceLen) 72 uLong ZEXPORT compressBound(uLong sourceLen) {
82 uLong sourceLen;
83 {
84 return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 73 return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
85 (sourceLen >> 25) + 13; 74 (sourceLen >> 25) + 13;
86 } 75 }