Skip to content

Commit 9b16a96

Browse files
committed
Update zlib dependency to 1.3.1
1 parent 903b3aa commit 9b16a96

25 files changed

+13168
-3249
lines changed

contrib/zlib/LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Copyright notice:
2+
3+
(C) 1995-2022 Jean-loup Gailly and Mark Adler
4+
5+
This software is provided 'as-is', without any express or implied
6+
warranty. In no event will the authors be held liable for any damages
7+
arising from the use of this software.
8+
9+
Permission is granted to anyone to use this software for any purpose,
10+
including commercial applications, and to alter it and redistribute it
11+
freely, subject to the following restrictions:
12+
13+
1. The origin of this software must not be misrepresented; you must not
14+
claim that you wrote the original software. If you use this software
15+
in a product, an acknowledgment in the product documentation would be
16+
appreciated but is not required.
17+
2. Altered source versions must be plainly marked as such, and must not be
18+
misrepresented as being the original software.
19+
3. This notice may not be removed or altered from any source distribution.
20+
21+
Jean-loup Gailly Mark Adler
22+

contrib/zlib/adler32.c

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
/* adler32.c -- compute the Adler-32 checksum of a data stream
2-
* Copyright (C) 1995-2011 Mark Adler
2+
* Copyright (C) 1995-2011, 2016 Mark Adler
33
* For conditions of distribution and use, see copyright notice in zlib.h
44
*/
55

66
/* @(#) $Id$ */
77

88
#include "zutil.h"
99

10-
#define local static
11-
12-
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
13-
14-
#define BASE 65521 /* largest prime smaller than 65536 */
10+
#define BASE 65521U /* largest prime smaller than 65536 */
1511
#define NMAX 5552
1612
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
1713

@@ -62,11 +58,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
6258
#endif
6359

6460
/* ========================================================================= */
65-
uLong ZEXPORT adler32(adler, buf, len)
66-
uLong adler;
67-
const Bytef *buf;
68-
uInt len;
69-
{
61+
uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
7062
unsigned long sum2;
7163
unsigned n;
7264

@@ -133,11 +125,12 @@ uLong ZEXPORT adler32(adler, buf, len)
133125
}
134126

135127
/* ========================================================================= */
136-
local uLong adler32_combine_(adler1, adler2, len2)
137-
uLong adler1;
138-
uLong adler2;
139-
z_off64_t len2;
140-
{
128+
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
129+
return adler32_z(adler, buf, len);
130+
}
131+
132+
/* ========================================================================= */
133+
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) {
141134
unsigned long sum1;
142135
unsigned long sum2;
143136
unsigned rem;
@@ -156,24 +149,16 @@ local uLong adler32_combine_(adler1, adler2, len2)
156149
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
157150
if (sum1 >= BASE) sum1 -= BASE;
158151
if (sum1 >= BASE) sum1 -= BASE;
159-
if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
152+
if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1);
160153
if (sum2 >= BASE) sum2 -= BASE;
161154
return sum1 | (sum2 << 16);
162155
}
163156

164157
/* ========================================================================= */
165-
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
166-
uLong adler1;
167-
uLong adler2;
168-
z_off_t len2;
169-
{
158+
uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) {
170159
return adler32_combine_(adler1, adler2, len2);
171160
}
172161

173-
uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
174-
uLong adler1;
175-
uLong adler2;
176-
z_off64_t len2;
177-
{
162+
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) {
178163
return adler32_combine_(adler1, adler2, len2);
179164
}

contrib/zlib/compress.c

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* compress.c -- compress a memory buffer
2-
* Copyright (C) 1995-2005 Jean-loup Gailly.
2+
* Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler
33
* For conditions of distribution and use, see copyright notice in zlib.h
44
*/
55

@@ -19,25 +19,15 @@
1919
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
2020
Z_STREAM_ERROR if the level parameter is invalid.
2121
*/
22-
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
23-
Bytef *dest;
24-
uLongf *destLen;
25-
const Bytef *source;
26-
uLong sourceLen;
27-
int level;
28-
{
22+
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
23+
uLong sourceLen, int level) {
2924
z_stream stream;
3025
int err;
26+
const uInt max = (uInt)-1;
27+
uLong left;
3128

32-
stream.next_in = (z_const Bytef *)source;
33-
stream.avail_in = (uInt)sourceLen;
34-
#ifdef MAXSEG_64K
35-
/* Check for source > 64K on 16-bit machine: */
36-
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
37-
#endif
38-
stream.next_out = dest;
39-
stream.avail_out = (uInt)*destLen;
40-
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
29+
left = *destLen;
30+
*destLen = 0;
4131

4232
stream.zalloc = (alloc_func)0;
4333
stream.zfree = (free_func)0;
@@ -46,35 +36,40 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
4636
err = deflateInit(&stream, level);
4737
if (err != Z_OK) return err;
4838

49-
err = deflate(&stream, Z_FINISH);
50-
if (err != Z_STREAM_END) {
51-
deflateEnd(&stream);
52-
return err == Z_OK ? Z_BUF_ERROR : err;
53-
}
54-
*destLen = stream.total_out;
39+
stream.next_out = dest;
40+
stream.avail_out = 0;
41+
stream.next_in = (z_const Bytef *)source;
42+
stream.avail_in = 0;
43+
44+
do {
45+
if (stream.avail_out == 0) {
46+
stream.avail_out = left > (uLong)max ? max : (uInt)left;
47+
left -= stream.avail_out;
48+
}
49+
if (stream.avail_in == 0) {
50+
stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
51+
sourceLen -= stream.avail_in;
52+
}
53+
err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
54+
} while (err == Z_OK);
5555

56-
err = deflateEnd(&stream);
57-
return err;
56+
*destLen = stream.total_out;
57+
deflateEnd(&stream);
58+
return err == Z_STREAM_END ? Z_OK : err;
5859
}
5960

6061
/* ===========================================================================
6162
*/
62-
int ZEXPORT compress (dest, destLen, source, sourceLen)
63-
Bytef *dest;
64-
uLongf *destLen;
65-
const Bytef *source;
66-
uLong sourceLen;
67-
{
63+
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
64+
uLong sourceLen) {
6865
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
6966
}
7067

7168
/* ===========================================================================
7269
If the default memLevel or windowBits for deflateInit() is changed, then
7370
this function needs to be updated.
7471
*/
75-
uLong ZEXPORT compressBound (sourceLen)
76-
uLong sourceLen;
77-
{
72+
uLong ZEXPORT compressBound(uLong sourceLen) {
7873
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
7974
(sourceLen >> 25) + 13;
8075
}

0 commit comments

Comments
 (0)