Skip to content

Commit

Permalink
zlib 0.95
Browse files Browse the repository at this point in the history
  • Loading branch information
madler committed Sep 10, 2011
1 parent 23c69f1 commit 25e5325
Show file tree
Hide file tree
Showing 15 changed files with 225 additions and 140 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@

ChangeLog file for zlib

Changes in 0.95 (16 Aug 95)
- fix MSDOS small and medium model (now easier to adapt to any compiler)
- inlined send_bits
- fix the final (:-) bug for deflate with flush (output was correct but
not completely flushed in rare occasions).
- default window size is same for compression and decompression
(it's now sufficient to set MAX_WBITS in zconf.h).
- voidp -> voidpf and voidnp -> voidp (for consistency with other
typedefs and because voidnp was not near in large model).

Changes in 0.94 (13 Aug 95)
- support MSDOS medium model
- fix deflate with flush (could sometimes generate bad output)
Expand All @@ -10,6 +20,7 @@ Changes in 0.94 (13 Aug 95)
- gzflush now calls fflush
- For deflate with flush, flush even if no more input is provided.
- rename libgz.a as libz.a
- avoid complex expression in infcodes.c triggering Turbo C bug
- work around a problem with gcc on Alpha (in INSERT_STRING)
- don't use inline functions (problem with some gcc versions)
- allow renaming of Byte, uInt, etc... with #define.
Expand Down
1 change: 1 addition & 0 deletions Makefile.bor
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Borland C++ ************ UNTESTED ***********

# To use, do "make -fmakefile.bor"
# To compile in small model, set below: MODEL=-ms

# WARNING: the small model is supported but only for small values of
# MAX_WBITS and MAX_MEM_LEVEL. For example:
Expand Down
1 change: 1 addition & 0 deletions Makefile.msc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Microsoft C 5.1 or later

# To use, do "make makefile.msc"
# To compile in small model, set below: MODEL=-AS

# If you wish to reduce the memory requirements (default 256K for big
# objects plus a few K), you can add to CFLAGS below:
Expand Down
4 changes: 3 additions & 1 deletion Makefile.tc
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
# TurboC 2.0

# To use, do "make -fmakefile.tc"
# To compile in small model, set below: MODEL=-ms

# WARNING: the small model is supported but only for small values of
# MAX_WBITS and MAX_MEM_LEVEL. For example:
# -DMAX_WBITS=11 -DDEF_WBITS=11 -DMAX_MEM_LEVEL=3
# -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
# If you wish to reduce the memory requirements (default 256K for big
# objects plus a few K), you can add to CFLAGS below:
# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14
# See zconf.h for details about the memory requirements.

# ------------- Turbo C 2.0 -------------
MODEL=-ml
# CFLAGS=-O2 -G -Z $(MODEL) -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
CFLAGS=-O2 -G -Z $(MODEL)
CC=tcc -I\tc\include
LD=tcc -L\tc\lib
Expand Down
39 changes: 19 additions & 20 deletions README
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
zlib 0.94 is a beta version of a general purpose compression library.
Unless new bugs are found it will be released again as the first official
version (1.0). This version has no known bugs.
zlib 0.95 is a beta version of a general purpose compression library.
This should be the last version before the first official
version (1.0), so please test it now. (At least compile and run it with
"make test"). This version has no known bugs.

The data format used by the zlib library is described in the
files zlib-3.1.doc, deflate-1.1.doc and gzip-4.1.doc, available
in ftp.uu.net:/pub/archiving/zip/doc.

All functions of the compression library are documented in the file
zlib.h. A usage example of the library is given in the file example.c
which also tests that the library is working correctly.
which also tests that the library is working correctly. Another
example is given in the file minigzip.c.

To compile all files and run the test program, just type: make test
(For MSDOS, use one of the special makefiles such as Makefile.msc.)
(For MSDOS, use one of the special makefiles such as Makefile.msc;
for VMS, use Make_vms.com or descrip.mms.)
To install the zlib library (libz.a) in /usr/local/lib, type: make install
To install in a different directory, use for example:
make install prefix=$HOME
This will install in $HOME/lib instead of /usr/local/lib.

The changes made in version 0.94 are documented in the file ChangeLog.
The main changes since 0.93 are:
- support MSDOS small and medium model
- fix deflate with flush (could sometimes generate bad output)
- fix deflateReset (zlib header was incorrectly suppressed)
- added support for VMS
- allow a compression level in gzopen()
- gzflush now calls fflush
- For deflate with flush, flush even if no more input is provided.
- rename libgz.a as libz.a
The changes made in version 0.95 are documented in the file ChangeLog.
The main changes since 0.94 are:
- fix MSDOS small and medium model (now easier to adapt to any compiler)
- inlined send_bits
- fix the final (:-) bug for deflate with flush (output was correct but
not completely flushed in rare occasions).

For MSDOS, the small and medium models are supported only for Microsoft C.
(It should be easy to support them for Borland C also, but I don't have
a recent Borland compiler to test with.) The small model currently works
for Turbo/Borland C but only with reduced performance to avoid any far
allocation (tested with -DMAX_WBITS=11 -DDEF_WBITS=11 -DMAX_MEM_LEVEL=3).
For MSDOS, the small and medium models have been tested only with Microsoft C.
(This should now work for Borland C also, but I don't have a recent Borland
compiler to test with.) The small model was tested with Turbo C but only with
reduced performance to avoid any far allocation; it was tested with
-DMAX_WBITS=11 -DMAX_MEM_LEVEL=3


(C) 1995 Jean-loup Gailly and Mark Adler
Expand Down
18 changes: 9 additions & 9 deletions deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,8 @@ local int longest_match(s, cur_match)
* Try with and without -DUNALIGNED_OK to check.
*/
register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
register ush scan_start = *(ush*)scan;
register ush scan_end = *(ush*)(scan+best_len-1);
register ush scan_start = *(ushf*)scan;
register ush scan_end = *(ushf*)(scan+best_len-1);
#else
register Bytef *strend = s->window + s->strstart + MAX_MATCH;
register Byte scan_end1 = scan[best_len-1];
Expand Down Expand Up @@ -554,8 +554,8 @@ local int longest_match(s, cur_match)
/* This code assumes sizeof(unsigned short) == 2. Do not use
* UNALIGNED_OK if your compiler uses a different size.
*/
if (*(ush*)(match+best_len-1) != scan_end ||
*(ush*)match != scan_start) continue;
if (*(ushf*)(match+best_len-1) != scan_end ||
*(ushf*)match != scan_start) continue;

/* It is not necessary to compare scan[2] and match[2] since they are
* always equal when the other bytes match, given that the hash keys
Expand All @@ -569,10 +569,10 @@ local int longest_match(s, cur_match)
Assert(scan[2] == match[2], "scan[2]?");
scan++, match++;
do {
} while (*(ush*)(scan+=2) == *(ush*)(match+=2) &&
*(ush*)(scan+=2) == *(ush*)(match+=2) &&
*(ush*)(scan+=2) == *(ush*)(match+=2) &&
*(ush*)(scan+=2) == *(ush*)(match+=2) &&
} while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
scan < strend);
/* The funny "do {}" generates better code on most compilers */

Expand Down Expand Up @@ -621,7 +621,7 @@ local int longest_match(s, cur_match)
best_len = len;
if (len >= s->nice_match) break;
#ifdef UNALIGNED_OK
scan_end = *(ush*)(scan+best_len-1);
scan_end = *(ushf*)(scan+best_len-1);
#else
scan_end1 = scan[best_len-1];
scan_end = scan[best_len];
Expand Down
1 change: 1 addition & 0 deletions deflate.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ typedef struct internal_state {
ulg static_len; /* bit length of current block with static trees */
ulg compressed_len; /* total bit length of compressed file */
uInt matches; /* number of string matches in current block */
int last_eob_len; /* bit length of EOB code for last block */

#ifdef DEBUG
ulg bits_sent; /* bit length of the compressed data */
Expand Down
2 changes: 1 addition & 1 deletion example.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ int main(argc, argv)
fprintf(stderr, "incompatible zlib version\n");
exit(1);

} else if (zstrcmp(zlib_version, ZLIB_VERSION) != 0) {
} else if (strcmp(zlib_version, ZLIB_VERSION) != 0) {
fprintf(stderr, "warning: different zlib version\n");
}
test_compress();
Expand Down
4 changes: 2 additions & 2 deletions gzio.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ gzFile gzdopen (fd, mode)
*/
int gzread (file, buf, len)
gzFile file;
voidnp buf;
voidp buf;
unsigned len;
{
gz_stream *s = (gz_stream*)file;
Expand Down Expand Up @@ -292,7 +292,7 @@ int gzread (file, buf, len)
*/
int gzwrite (file, buf, len)
gzFile file;
voidnp buf;
voidp buf;
unsigned len;
{
gz_stream *s = (gz_stream*)file;
Expand Down
18 changes: 9 additions & 9 deletions inftrees.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ local int huft_build OF((
uIntf *, /* maximum lookup bits (returns actual) */
z_stream *)); /* for zalloc function */

local voidp falloc OF((
voidp, /* opaque pointer (not used) */
local voidpf falloc OF((
voidpf, /* opaque pointer (not used) */
uInt, /* number of items */
uInt)); /* size of item */

local void ffree OF((
voidp q, /* opaque pointer (not used) */
voidp p)); /* what to free (not used) */
voidpf q, /* opaque pointer (not used) */
voidpf p)); /* what to free (not used) */

/* Tables for deflate from PKZIP's appnote.txt. */
local uInt cplens[] = { /* Copy lengths for literal codes 257..285 */
Expand Down Expand Up @@ -377,22 +377,22 @@ local inflate_huft *fixed_tl;
local inflate_huft *fixed_td;


local voidp falloc(q, n, s)
voidp q; /* opaque pointer (not used) */
local voidpf falloc(q, n, s)
voidpf q; /* opaque pointer (not used) */
uInt n; /* number of items */
uInt s; /* size of item */
{
Assert(s == sizeof(inflate_huft) && n <= fixed_left,
"inflate_trees falloc overflow");
if (q) s++; /* to make some compilers happy */
fixed_left -= n;
return (voidp)(fixed_mem + fixed_left);
return (voidpf)(fixed_mem + fixed_left);
}


local void ffree(q, p)
voidp q;
voidp p;
voidpf q;
voidpf p;
{
Assert(0, "inflate_trees ffree called!");
if (q) q = p; /* to make some compilers happy */
Expand Down
Loading

0 comments on commit 25e5325

Please sign in to comment.