Skip to content

Commit

Permalink
Import zlib-1.2.3 library
Browse files Browse the repository at this point in the history
--BZR--
revision-id: [email protected]
property-file-info: ld7:file_id62:sp1f-changelog-20020319040621-vzynw3obxgphyndm5taanrhzm5jdjj337:message18:Import zlib-1.2.3
property-file-info: 4:path14:zlib/ChangeLoged7:file_id56:sp1f-faq-20020319040627-y73xbdo6p2eha6ok26fewvbgqltw7fs77:message18:Import zlib-1.2.3
property-file-info: 4:path8:zlib/FAQed7:file_id59:sp1f-readme-20020319040630-tlwzszyuhbomqvo4rsifyfxlv5muf7sh7:message18:Import zlib-1.2.3
property-file-info: 4:path11:zlib/READMEed7:file_id62:sp1f-adler32.c-20020319040622-2zfj5dembf2fkxxsrsxv5iuvay6m5e2x7:message18:Import zlib-1.2.3
property-file-info: 4:path14:zlib/adler32.ced7:file_id63:sp1f-compress.c-20020319040622-afnrpjb4skm63oz4aesnkeqq7tg636xl7:message18:Import zlib-1.2.3
property-file-info: 4:path15:zlib/compress.ced7:file_id60:sp1f-crc32.c-20020319040626-7kcq3mxw5mtkoxbdgca5mdzh2qe7ekww7:message18:Import zlib-1.2.3
property-file-info: 4:path12:zlib/crc32.ced7:file_id62:sp1f-deflate.c-20020319040626-pvnutdtisme5trayecgygzakxxh3k34d7:message18:Import zlib-1.2.3
property-file-info: 4:path14:zlib/deflate.ced7:file_id62:sp1f-deflate.h-20020319040626-3rvhbgntavblmgz6u5mpzfm2wrxy3r7d7:message18:Import zlib-1.2.3
property-file-info: 4:path14:zlib/deflate.hed7:file_id59:sp1f-gzio.c-20020319040627-dzt3rl3kklylxis35ym3ldjtzvu7xagn7:message18:Import zlib-1.2.3
property-file-info: 4:path11:zlib/gzio.ced7:file_id62:sp1f-infback.c-20040722003606-xz4hkef77h2ahwypdnupixykujfse3o27:message18:Import zlib-1.2.3
property-file-info: 4:path14:zlib/infback.ced7:file_id62:sp1f-inffast.c-20020319040627-2kfc5z3laqnioy3haqpp2riiscbxqcb37:message18:Import zlib-1.2.3
property-file-info: 4:path14:zlib/inffast.ced7:file_id62:sp1f-inflate.c-20020319040628-hqxouxf7lwvfng4n4rznwmyioeljq3jq7:message18:Import zlib-1.2.3
property-file-info: 4:path14:zlib/inflate.ced7:file_id62:sp1f-inflate.h-20040722003606-uqt2csoc6i7e4jhxa7q3m3ynmmrf6w2k7:message18:Import zlib-1.2.3
property-file-info: 4:path14:zlib/inflate.hed7:file_id63:sp1f-inftrees.c-20020319040628-r2puxnzva6kky4rj7tojn3g3iqvou7vb7:message18:Import zlib-1.2.3
property-file-info: 4:path15:zlib/inftrees.ced7:file_id63:sp1f-inftrees.h-20020319040628-5oha2jaj6jkwbljrgqpq3gcurthvtv4g7:message18:Import zlib-1.2.3
property-file-info: 4:path15:zlib/inftrees.hed7:file_id60:sp1f-trees.c-20020319040630-cel2mj22njx6gybjrzba3edupgv6hdjo7:message18:Import zlib-1.2.3
property-file-info: 4:path12:zlib/trees.ced7:file_id60:sp1f-zconf.h-20020319040630-62xy5ky2pnjnjc5qojs7wukj3izekyem7:message18:Import zlib-1.2.3
property-file-info: 4:path12:zlib/zconf.hed7:file_id59:sp1f-zlib.3-20020319040630-l5vfiw3h2asojcpnonnmwnpzuguctpkk7:message18:Import zlib-1.2.3
property-file-info: 4:path11:zlib/zlib.3ed7:file_id59:sp1f-zlib.h-20020319040631-cwzpdj7hpyh4gff7vps3f5sbvb4yyzqn7:message18:Import zlib-1.2.3
property-file-info: 4:path11:zlib/zlib.hed7:file_id60:sp1f-zutil.c-20020319040631-7fcaws3vfoxwzxi7vhirha2p2zug4xmi7:message18:Import zlib-1.2.3
property-file-info: 4:path12:zlib/zutil.ced7:file_id60:sp1f-zutil.h-20020319040631-b5zbeixsmnfoxpngztqq6piqvgu3owgj7:message18:Import zlib-1.2.3
property-file-info: 4:path12:zlib/zutil.hed7:file_id65:sp1f-readme.mysql-20050809172244-zyv7gw2pyjlyogwrtd5pvmwjiz6nmoc67:message18:Import zlib-1.2.3
property-file-info: 4:path17:zlib/README.MySQLee
property-sp1-file-info: ld9:commit_id50:[email protected]|zlib/ChangeLog|20050809144742|135237:file_id71:[email protected]|zlib/ChangeLog|20020319040621|53148|b9187d8041adeb0aed9:commit_id44:[email protected]|zlib/FAQ|20050809144747|580477:file_id65:[email protected]|zlib/faq|20020319040627|20385|c90133f095701f56ed9:commit_id47:[email protected]|zlib/README|20050809144749|498827:file_id68:[email protected]|zlib/readme|20020319040630|41568|e0c9aef3f38f994ced9:commit_id50:[email protected]|zlib/adler32.c|20050809144750|286837:file_id71:[email protected]|zlib/adler32.c|20020319040622|10787|fb17dc5beb30afa9ed9:commit_id51:[email protected]|zlib/compress.c|20050809144751|009057:file_id72:[email protected]|zlib/compress.c|20020319040622|48839|47f9466d8c464b57ed9:commit_id48:[email protected]|zlib/crc32.c|20050809144752|453907:file_id69:[email protected]|zlib/crc32.c|20020319040626|05988|3f8a3375ecdf773bed9:commit_id50:[email protected]|zlib/deflate.c|20050809144753|193577:file_id70:[email protected]|zlib/deflate.c|20020319040626|15662|ce5b7454cf6a007ed9:commit_id50:[email protected]|zlib/deflate.h|20050809144753|481107:file_id71:[email protected]|zlib/deflate.h|20020319040626|25775|4b2da0ceecc72443ed9:commit_id47:[email protected]|zlib/gzio.c|20050809144754|380727:file_id67:[email protected]|zlib/gzio.c|20020319040627|30031|d44c68d16891667ed9:commit_id50:[email protected]|zlib/infback.c|20050809144754|101017:file_id73:[email protected]|zlib/infback.c|20040722003606|19957|85e6778d21383f99ed9:commit_id50:[email protected]|zlib/inffast.c|20050809144755|442107:file_id71:[email protected]|zlib/inffast.c|20020319040627|22704|f149169919917162ed9:commit_id50:[email protected]|zlib/inflate.c|20050809144755|122117:file_id70:[email protected]|zlib/inflate.c|20020319040628|17357|da0498a8a338ba0ed9:commit_id50:[email protected]|zlib/inflate.h|20050809144756|478597:file_id73:[email protected]|zlib/inflate.h|20040722003606|33413|dac706f4a86c7ca5ed9:commit_id51:[email protected]|zlib/inftrees.c|20050809144757|346277:file_id72:[email protected]|zlib/inftrees.c|20020319040628|27095|ded2728360d379fded9:commit_id51:[email protected]|zlib/inftrees.h|20050809144758|646867:file_id72:[email protected]|zlib/inftrees.h|20020319040628|37034|6a48d51982ad51eded9:commit_id48:[email protected]|zlib/trees.c|20050809144759|388257:file_id69:[email protected]|zlib/trees.c|20020319040630|51504|68d5ad14f958370ded9:commit_id48:[email protected]|zlib/zconf.h|20050809144759|141467:file_id69:[email protected]|zlib/zconf.h|20020319040630|15555|3f2505051217a409ed9:commit_id47:[email protected]|zlib/zlib.3|20050809144800|049047:file_id68:[email protected]|zlib/zlib.3|20020319040630|25413|651ea45f3b0196e0ed9:commit_id47:[email protected]|zlib/zlib.h|20050809144800|587257:file_id68:[email protected]|zlib/zlib.h|20020319040631|10528|ae8e4a1273f662fced9:commit_id48:[email protected]|zlib/zutil.c|20050809144801|032867:file_id69:[email protected]|zlib/zutil.c|20020319040631|30872|78f3d437ac8edd5bed9:commit_id48:[email protected]|zlib/zutil.h|20050809144801|130557:file_id69:[email protected]|zlib/zutil.h|20020319040631|40683|f0d0a3f5ed9a8bbded9:commit_id53:[email protected]|zlib/README.MySQL|20050809172245|250467:file_id70:[email protected]|zlib/README.MySQL|20050809172244|34489|f927cd97d524db5fee
testament3-sha1: fc107ac531f6f7077ea667005aeaf3b9d066d168
  • Loading branch information
[email protected] committed Aug 9, 2005
1 parent 6ae2124 commit 7f0fede
Show file tree
Hide file tree
Showing 23 changed files with 1,008 additions and 213 deletions.
Binary file modified .bzrfileids
Binary file not shown.
98 changes: 92 additions & 6 deletions zlib/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,10 +1,96 @@

ChangeLog file for zlib
Changes in port for MySQL (19 July 2004)
- removed contrib, nt, os2, amiga, directories and some other files not used
in MySQL distribution. If you are working on porting MySQL to one of rare
platforms, you might find worth looking at the original zlib distribution
and using appropriate Makefiles/project files from it.

Changes in 1.2.3 (18 July 2005)
- Apply security vulnerability fixes to contrib/infback9 as well
- Clean up some text files (carriage returns, trailing space)
- Update testzlib, vstudio, masmx64, and masmx86 in contrib [Vollant]

Changes in 1.2.2.4 (11 July 2005)
- Add inflatePrime() function for starting inflation at bit boundary
- Avoid some Visual C warnings in deflate.c
- Avoid more silly Visual C warnings in inflate.c and inftrees.c for 64-bit
compile
- Fix some spelling errors in comments [Betts]
- Correct inflateInit2() error return documentation in zlib.h
- Added zran.c example of compressed data random access to examples
directory, shows use of inflatePrime()
- Fix cast for assignments to strm->state in inflate.c and infback.c
- Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer]
- Move declarations of gf2 functions to right place in crc32.c [Oberhumer]
- Add cast in trees.c t avoid a warning [Oberhumer]
- Avoid some warnings in fitblk.c, gun.c, gzjoin.c in examples [Oberhumer]
- Update make_vms.com [Zinser]
- Initialize state->write in inflateReset() since copied in inflate_fast()
- Be more strict on incomplete code sets in inflate_table() and increase
ENOUGH and MAXD -- this repairs a possible security vulnerability for
invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for
discovering the vulnerability and providing test cases.
- Add ia64 support to configure for HP-UX [Smith]
- Add error return to gzread() for format or i/o error [Levin]
- Use malloc.h for OS/2 [Necasek]

Changes in 1.2.2.3 (27 May 2005)
- Replace 1U constants in inflate.c and inftrees.c for 64-bit compile
- Typecast fread() return values in gzio.c [Vollant]
- Remove trailing space in minigzip.c outmode (VC++ can't deal with it)
- Fix crc check bug in gzread() after gzungetc() [Heiner]
- Add the deflateTune() function to adjust internal compression parameters
- Add a fast gzip decompressor, gun.c, to examples (use of inflateBack)
- Remove an incorrect assertion in examples/zpipe.c
- Add C++ wrapper in infback9.h [Donais]
- Fix bug in inflateCopy() when decoding fixed codes
- Note in zlib.h how much deflateSetDictionary() actually uses
- Remove USE_DICT_HEAD in deflate.c (would mess up inflate if used)
- Add _WIN32_WCE to define WIN32 in zconf.in.h [Spencer]
- Don't include stderr.h or errno.h for _WIN32_WCE in zutil.h [Spencer]
- Add gzdirect() function to indicate transparent reads
- Update contrib/minizip [Vollant]
- Fix compilation of deflate.c when both ASMV and FASTEST [Oberhumer]
- Add casts in crc32.c to avoid warnings [Oberhumer]
- Add contrib/masmx64 [Vollant]
- Update contrib/asm586, asm686, masmx86, testzlib, vstudio [Vollant]

Changes in 1.2.2.2 (30 December 2004)
- Replace structure assignments in deflate.c and inflate.c with zmemcpy to
avoid implicit memcpy calls (portability for no-library compilation)
- Increase sprintf() buffer size in gzdopen() to allow for large numbers
- Add INFLATE_STRICT to check distances against zlib header
- Improve WinCE errno handling and comments [Chang]
- Remove comment about no gzip header processing in FAQ
- Add Z_FIXED strategy option to deflateInit2() to force fixed trees
- Add updated make_vms.com [Coghlan], update README
- Create a new "examples" directory, move gzappend.c there, add zpipe.c,
fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html.
- Add FAQ entry and comments in deflate.c on uninitialized memory access
- Add Solaris 9 make options in configure [Gilbert]
- Allow strerror() usage in gzio.c for STDC
- Fix DecompressBuf in contrib/delphi/ZLib.pas [ManChesTer]
- Update contrib/masmx86/inffas32.asm and gvmat32.asm [Vollant]
- Use z_off_t for adler32_combine() and crc32_combine() lengths
- Make adler32() much faster for small len
- Use OS_CODE in deflate() default gzip header

Changes in 1.2.2.1 (31 October 2004)
- Allow inflateSetDictionary() call for raw inflate
- Fix inflate header crc check bug for file names and comments
- Add deflateSetHeader() and gz_header structure for custom gzip headers
- Add inflateGetheader() to retrieve gzip headers
- Add crc32_combine() and adler32_combine() functions
- Add alloc_func, free_func, in_func, out_func to Z_PREFIX list
- Use zstreamp consistently in zlib.h (inflate_back functions)
- Remove GUNZIP condition from definition of inflate_mode in inflate.h
and in contrib/inflate86/inffast.S [Truta, Anderson]
- Add support for AMD64 in contrib/inflate86/inffas86.c [Anderson]
- Update projects/README.projects and projects/visualc6 [Truta]
- Update win32/DLL_FAQ.txt [Truta]
- Avoid warning under NO_GZCOMPRESS in gzio.c; fix typo [Truta]
- Deprecate Z_ASCII; use Z_TEXT instead [Truta]
- Use a new algorithm for setting strm->data_type in trees.c [Truta]
- Do not define an exit() prototype in zutil.c unless DEBUG defined
- Remove prototype of exit() from zutil.c, example.c, minigzip.c [Truta]
- Add comment in zlib.h for Z_NO_FLUSH parameter to deflate()
- Fix Darwin build version identification [Peterson]

Changes in 1.2.2 (3 October 2004)
- Update zlib.h comments on gzip in-memory processing
Expand Down Expand Up @@ -454,7 +540,7 @@ Changes in 1.0.7 (20 Jan 1998)
Changes in 1.0.6 (19 Jan 1998)
- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and
gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code)
- Fix a deflate bug occuring only with compression level 0 (thanks to
- Fix a deflate bug occurring only with compression level 0 (thanks to
Andy Buckler for finding this one).
- In minigzip, pass transparently also the first byte for .Z files.
- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress()
Expand Down
26 changes: 14 additions & 12 deletions zlib/FAQ
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,6 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
format using deflateInit2(). You can also request that inflate decode
the gzip format using inflateInit2(). Read zlib.h for more details.

Note that you cannot specify special gzip header contents (e.g. a file
name or modification date), nor will inflate tell you what was in the
gzip header. If you need to customize the header or see what's in it,
you can use the raw deflate and inflate operations and the crc32()
function and roll your own gzip encoding and decoding. Read the gzip
RFC 1952 for details of the header and trailer format.

21. Is zlib thread-safe?

Yes. However any library routines that zlib uses and any application-
Expand Down Expand Up @@ -295,20 +288,29 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
were downright silly. So now, we simply make sure that the code always
works.

36. Will zlib read the (insert any ancient or arcane format here) compressed
36. Valgrind (or some similar memory access checker) says that deflate is
performing a conditional jump that depends on an uninitialized value.
Isn't that a bug?

No. That is intentional for performance reasons, and the output of
deflate is not affected. This only started showing up recently since
zlib 1.2.x uses malloc() by default for allocations, whereas earlier
versions used calloc(), which zeros out the allocated memory.

37. Will zlib read the (insert any ancient or arcane format here) compressed
data format?

Probably not. Look in the comp.compression FAQ for pointers to various
formats and associated software.

37. How can I encrypt/decrypt zip files with zlib?
38. How can I encrypt/decrypt zip files with zlib?

zlib doesn't support encryption. The original PKZIP encryption is very weak
and can be broken with freely available programs. To get strong encryption,
use GnuPG, http://www.gnupg.org/ , which already includes zlib compression.
For PKZIP compatible "encryption", look at http://www.info-zip.org/

38. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?

"gzip" is the gzip format, and "deflate" is the zlib format. They should
probably have called the second one "zlib" instead to avoid confusion
Expand All @@ -324,14 +326,14 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html

Bottom line: use the gzip format for HTTP 1.1 encoding.

39. Does zlib support the new "Deflate64" format introduced by PKWare?
40. Does zlib support the new "Deflate64" format introduced by PKWare?

No. PKWare has apparently decided to keep that format proprietary, since
they have not documented it as they have previous compression formats.
In any case, the compression improvements are so modest compared to other
more modern approaches, that it's not worth the effort to implement.

40. Can you please sign these lengthy legal documents and fax them back to us
41. Can you please sign these lengthy legal documents and fax them back to us
so that we can use your software in our product?

No. Go away. Shoo.
9 changes: 4 additions & 5 deletions zlib/README
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ZLIB DATA COMPRESSION LIBRARY

zlib 1.2.2 is a general purpose data compression library. All the code is
zlib 1.2.3 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
Expand All @@ -16,9 +16,8 @@ minigzip.c.

To compile all files and run the test program, follow the instructions given at
the top of Makefile. In short "make test; make install" should work for most
machines. For Unix: "./configure; make test; make install" For MSDOS, use one
of the special makefiles such as Makefile.msc. For VMS, use Make_vms.com or
descrip.mms.
machines. For Unix: "./configure; make test; make install". For MSDOS, use one
of the special makefiles such as Makefile.msc. For VMS, use make_vms.com.

Questions about zlib should be sent to <[email protected]>, or to Gilles Vollant
<[email protected]> for the Windows DLL version. The zlib home page is
Expand All @@ -34,7 +33,7 @@ Mark Nelson <[email protected]> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available in
http://dogma.net/markn/articles/zlibtool/zlibtool.htm

The changes made in version 1.2.2 are documented in the file ChangeLog.
The changes made in version 1.2.3 are documented in the file ChangeLog.

Unsupported third party contributions are provided in directory "contrib".

Expand Down
7 changes: 7 additions & 0 deletions zlib/README.MySQL
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This an incomplete version of the zlib library -- it excludes some of the
platform-specific project files, contributed code, and examples from the
original zlib distribution. You can find the original distribution at

http://www.gzip.org/zlib/
or
http://www.zlib.net/
111 changes: 93 additions & 18 deletions zlib/adler32.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* adler32.c -- compute the Adler-32 checksum of a data stream
* Copyright (C) 1995-2003 Mark Adler
* Copyright (C) 1995-2004 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

Expand All @@ -12,12 +12,13 @@
#define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */

#define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
#define DO16(buf) DO8(buf,0); DO8(buf,8);

/* use NO_DIVIDE if your processor does not do division in hardware */
#ifdef NO_DIVIDE
# define MOD(a) \
do { \
Expand All @@ -39,8 +40,17 @@
if (a >= (BASE << 1)) a -= (BASE << 1); \
if (a >= BASE) a -= BASE; \
} while (0)
# define MOD4(a) \
do { \
if (a >= (BASE << 4)) a -= (BASE << 4); \
if (a >= (BASE << 3)) a -= (BASE << 3); \
if (a >= (BASE << 2)) a -= (BASE << 2); \
if (a >= (BASE << 1)) a -= (BASE << 1); \
if (a >= BASE) a -= BASE; \
} while (0)
#else
# define MOD(a) a %= BASE
# define MOD4(a) a %= BASE
#endif

/* ========================================================================= */
Expand All @@ -49,26 +59,91 @@ uLong ZEXPORT adler32(adler, buf, len)
const Bytef *buf;
uInt len;
{
unsigned long s1 = adler & 0xffff;
unsigned long s2 = (adler >> 16) & 0xffff;
int k;
unsigned long sum2;
unsigned n;

/* split Adler-32 into component sums */
sum2 = (adler >> 16) & 0xffff;
adler &= 0xffff;

/* in case user likes doing a byte at a time, keep it fast */
if (len == 1) {
adler += buf[0];
if (adler >= BASE)
adler -= BASE;
sum2 += adler;
if (sum2 >= BASE)
sum2 -= BASE;
return adler | (sum2 << 16);
}

if (buf == Z_NULL) return 1L;
/* initial Adler-32 value (deferred check for len == 1 speed) */
if (buf == Z_NULL)
return 1L;

while (len > 0) {
k = len < NMAX ? (int)len : NMAX;
len -= k;
while (k >= 16) {
/* in case short lengths are provided, keep it somewhat fast */
if (len < 16) {
while (len--) {
adler += *buf++;
sum2 += adler;
}
if (adler >= BASE)
adler -= BASE;
MOD4(sum2); /* only added so many BASE's */
return adler | (sum2 << 16);
}

/* do length NMAX blocks -- requires just one modulo operation */
while (len >= NMAX) {
len -= NMAX;
n = NMAX / 16; /* NMAX is divisible by 16 */
do {
DO16(buf); /* 16 sums unrolled */
buf += 16;
} while (--n);
MOD(adler);
MOD(sum2);
}

/* do remaining bytes (less than NMAX, still just one modulo) */
if (len) { /* avoid modulos if none remaining */
while (len >= 16) {
len -= 16;
DO16(buf);
buf += 16;
k -= 16;
}
if (k != 0) do {
s1 += *buf++;
s2 += s1;
} while (--k);
MOD(s1);
MOD(s2);
while (len--) {
adler += *buf++;
sum2 += adler;
}
MOD(adler);
MOD(sum2);
}
return (s2 << 16) | s1;

/* return recombined sums */
return adler | (sum2 << 16);
}

/* ========================================================================= */
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
uLong adler1;
uLong adler2;
z_off_t len2;
{
unsigned long sum1;
unsigned long sum2;
unsigned rem;

/* the derivation of this formula is left as an exercise for the reader */
rem = (unsigned)(len2 % BASE);
sum1 = adler1 & 0xffff;
sum2 = rem * sum1;
MOD(sum2);
sum1 += (adler2 & 0xffff) + BASE - 1;
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
if (sum1 > BASE) sum1 -= BASE;
if (sum1 > BASE) sum1 -= BASE;
if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
if (sum2 > BASE) sum2 -= BASE;
return sum1 | (sum2 << 16);
}
2 changes: 1 addition & 1 deletion zlib/compress.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* compress.c -- compress a memory buffer
* Copyright (C) 1995-2002 Jean-loup Gailly.
* Copyright (C) 1995-2003 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/

Expand Down
Loading

0 comments on commit 7f0fede

Please sign in to comment.