summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--Makefile15
-rw-r--r--Makefile.bak59
-rw-r--r--Makefile.bor5
-rw-r--r--Makefile.msc5
-rw-r--r--Makefile.tc5
-rw-r--r--README30
-rw-r--r--deflate.c11
-rw-r--r--example.c6
-rw-r--r--gzio.c6
-rw-r--r--inflate.c11
-rw-r--r--minigzip.c4
-rw-r--r--zconf.h17
-rw-r--r--zlib.h7
-rw-r--r--zutil.c23
-rw-r--r--zutil.h12
16 files changed, 125 insertions, 101 deletions
diff --git a/ChangeLog b/ChangeLog
index 54470f2..e97948e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
1 ChangeLog file for zlib 1 ChangeLog file for zlib
2 2
3Changes in 0.91 (2 May 95)
4- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h
5- Document the memory requirements in zconf.h
6- added "make install"
7- fix sync search logic in inflateSync
8- deflate(Z_FULL_FLUSH) now works even if output buffer too short
9- after inflateSync, don't scare people with just "lo world"
10- added support for DJGPP
11
3Changes in 0.9 (1 May 95) 12Changes in 0.9 (1 May 95)
4- don't assume that zalloc clears the allocated memory (the TurboC bug 13- don't assume that zalloc clears the allocated memory (the TurboC bug
5 was Mark's bug after all :) 14 was Mark's bug after all :)
@@ -10,6 +19,7 @@ Changes in 0.9 (1 May 95)
10- document explicitly that zalloc(64K) on MSDOS must return a normalized 19- document explicitly that zalloc(64K) on MSDOS must return a normalized
11 pointer (zero offset) 20 pointer (zero offset)
12- added Makefiles for Microsoft C, Turbo C, Borland C++ 21- added Makefiles for Microsoft C, Turbo C, Borland C++
22- faster crc32()
13 23
14Changes in 0.8 (29 April 95) 24Changes in 0.8 (29 April 95)
15- added fast inflate (inffast.c) 25- added fast inflate (inffast.c)
diff --git a/Makefile b/Makefile
index f251670..9a48249 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,17 @@
1# Makefile for zlib
2# Copyright (C) 1995 Jean-loup Gailly.
3# For conditions of distribution and use, see copyright notice in zlib.h
4
1CC=cc 5CC=cc
2CFLAGS=-O 6CFLAGS=-O
7#CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
3#CFLAGS=-g -DDEBUG 8#CFLAGS=-g -DDEBUG
4LDFLAGS=-L. -lgz 9LDFLAGS=-L. -lgz
5 10
6RANLIB=ranlib 11RANLIB=ranlib
7 12
13prefix=/usr/local
14
8OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ 15OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
9 zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o 16 zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
10 17
@@ -16,6 +23,14 @@ test: all
16 ./example 23 ./example
17 echo hello world | ./minigzip | ./minigzip -d 24 echo hello world | ./minigzip | ./minigzip -d
18 25
26install: libgz.a
27 -@mkdir $(prefix)/include
28 -@mkdir $(prefix)/lib
29 cp zlib.h zconf.h $(prefix)/include
30 chmod 644 $(prefix)/include/zlib.h $(prefix)/include/zconf.h
31 cp libgz.a $(prefix)/lib
32 chmod 644 $(prefix)/lib/libgz.a
33
19libgz.a: $(OBJS) 34libgz.a: $(OBJS)
20 ar rc $@ $(OBJS) 35 ar rc $@ $(OBJS)
21 $(RANLIB) $@ 36 $(RANLIB) $@
diff --git a/Makefile.bak b/Makefile.bak
deleted file mode 100644
index bfe1b74..0000000
--- a/Makefile.bak
+++ /dev/null
@@ -1,59 +0,0 @@
1CC=gcc
2CFLAGS=-O2
3#CFLAGS=-g -DDEBUG
4LDFLAGS=-L. -lgz
5
6RANLIB=ranlib
7
8OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
9 zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
10
11TEST_OBJS = example.o minigzip.o inftest.o
12
13all: example minigzip inftest
14
15test: all
16 ./example
17 echo hello world | ./minigzip | ./minigzip -d
18
19libgz.a: $(OBJS)
20 ar rc $@ $(OBJS)
21 $(RANLIB) $@
22
23example: example.o libgz.a
24 $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
25
26minigzip: minigzip.o libgz.a
27 $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
28
29inftest: inftest.o libgz.a
30 $(CC) $(CFLAGS) -o $@ inftest.o $(LDFLAGS)
31
32clean:
33 rm -f *.o example minigzip inftest libgz.a foo.gz
34
35zip:
36 zip -ul9 zlib README ChangeLog Makefile *.[ch]
37
38tgz:
39 cd ..; tar cfz zlib/zlib.tgz zlib/README zlib/ChangeLog zlib/Makefile \
40 zlib/*.[ch]
41
42# DO NOT DELETE THIS LINE -- make depend depends on it.
43
44adler32.o: zutil.h zlib.h zconf.h
45compress.o: zlib.h zconf.h
46crc32.o: zutil.h zlib.h zconf.h
47deflate.o: deflate.h zutil.h zlib.h zconf.h
48example.o: zlib.h zconf.h
49gzio.o: zutil.h zlib.h zconf.h
50infblock.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h
51infcodes.o: zutil.h zlib.h zconf.h inftrees.h infutil.h infcodes.h
52inflate.o: zutil.h zlib.h zconf.h infblock.h
53inftest.o: zutil.h zlib.h zconf.h
54inftrees.o: zutil.h zlib.h zconf.h inftrees.h
55infutil.o: zutil.h zlib.h zconf.h inftrees.h infutil.h
56minigzip.o: zlib.h zconf.h
57trees.o: deflate.h zutil.h zlib.h zconf.h
58uncompr.o: zlib.h zconf.h
59zutil.o: zutil.h zlib.h zconf.h
diff --git a/Makefile.bor b/Makefile.bor
index 877ed62..732ea5d 100644
--- a/Makefile.bor
+++ b/Makefile.bor
@@ -4,7 +4,10 @@
4# To use, do "make -fmakefile.bor" 4# To use, do "make -fmakefile.bor"
5 5
6# WARNING: the small model is supported but only for small values of 6# WARNING: the small model is supported but only for small values of
7# MAX_WBITS and MAX_MEM_LEVEL 7# MAX_WBITS and MAX_MEM_LEVEL. If you wish to reduce the memory
8# requirements (default 256K for big objects plus a few K), you can add
9# to CFLAGS below: -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14
10# See zconf.h for details about the memory requirements.
8 11
9# ------------- Turbo C++, Borland C++ ------------- 12# ------------- Turbo C++, Borland C++ -------------
10MODEL=-ml 13MODEL=-ml
diff --git a/Makefile.msc b/Makefile.msc
index 375d21c..d6899d8 100644
--- a/Makefile.msc
+++ b/Makefile.msc
@@ -4,7 +4,10 @@
4# To use, do "make makefile.msc" 4# To use, do "make makefile.msc"
5 5
6# WARNING: the small model is supported but only for small values of 6# WARNING: the small model is supported but only for small values of
7# MAX_WBITS and MAX_MEM_LEVEL 7# MAX_WBITS and MAX_MEM_LEVEL. If you wish to reduce the memory
8# requirements (default 256K for big objects plus a few K), you can add
9# to CFLAGS below: -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14
10# See zconf.h for details about the memory requirements.
8 11
9# ------------- Microsoft C 5.1 and later ------------- 12# ------------- Microsoft C 5.1 and later -------------
10MODEL=-AL 13MODEL=-AL
diff --git a/Makefile.tc b/Makefile.tc
index 51075f7..e173a55 100644
--- a/Makefile.tc
+++ b/Makefile.tc
@@ -4,7 +4,10 @@
4# To use, do "make -fmakefile.tc" 4# To use, do "make -fmakefile.tc"
5 5
6# WARNING: the small model is supported but only for small values of 6# WARNING: the small model is supported but only for small values of
7# MAX_WBITS and MAX_MEM_LEVEL 7# MAX_WBITS and MAX_MEM_LEVEL. If you wish to reduce the memory
8# requirements (default 256K for big objects plus a few K), you can add
9# to CFLAGS below: -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14
10# See zconf.h for details about the memory requirements.
8 11
9# ------------- Turbo C 2.0 ------------- 12# ------------- Turbo C 2.0 -------------
10MODEL=-ml 13MODEL=-ml
diff --git a/README b/README
index 0c718f1..caeccb9 100644
--- a/README
+++ b/README
@@ -1,25 +1,31 @@
1zlib 0.9 is a beta version of a general purpose compression library. 1zlib 0.91 is a beta version of a general purpose compression library.
2 2
3The data format used by the zlib library is described in the 3The data format used by the zlib library is described in the
4file zlib-3.1.doc, deflate-1.1.doc and gzip-4.1.doc, available 4files zlib-3.1.doc, deflate-1.1.doc and gzip-4.1.doc, available
5in ftp.uu.net:/pub/archiving/zip/doc. 5in ftp.uu.net:/pub/archiving/zip/doc.
6 6
7All functions of the compression library are documented in the file 7All functions of the compression library are documented in the file
8zlib.h. A usage example of the library is given in the file example.c 8zlib.h. A usage example of the library is given in the file example.c
9which also tests that the library is working correctly. 9which also tests that the library is working correctly.
10To compile all files and run the test program, just type: make test
11 10
12The changes made in version 0.9 are documented in the file ChangeLog. 11To compile all files and run the test program, just type: make test
13The main changes since 0.8 are: 12(For MSDOS, use one of the special makefiles such as Makefile.msc.)
14- don't assume that zalloc clears the allocated memory 13To install the zlib library (libgz.a) in /usr/local/lib, type: make install
15- let again gzread copy uncompressed data unchanged (was working in 0.71) 14To install in a different directory, use for example: make install prefix=$HOME
16- deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented 15This will install in $HOME/lib instead of /usr/local/lib.
16
17The changes made in version 0.91 are documented in the file ChangeLog.
18The main changes since 0.9 are:
19- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h
20- Document the memory requirements in zconf.h
21- added "make install"
22- added support for DJGPP
17 23
18On MSDOS, this version works in both large and small model. However 24On MSDOS, this version works in both large and small model. However
19small model compression works only for small values of MEM_LEVEL and 25small model compression works only for small values of MAX_MEM_LEVEL
20WBITS (see zutil.h). Small model decompression should work up to WBITS=15. 26and MAX_WBITS (see zconf.h). Small model decompression should work up
21This version of zlib does not support small or medium model with far 27to MAX_WBITS=15. This version of zlib does not support small or
22allocation of big objects. 28medium model with far allocation of big objects.
23 29
24 30
25 Copyright (C) 1995 Jean-loup Gailly and Mark Adler 31 Copyright (C) 1995 Jean-loup Gailly and Mark Adler
diff --git a/deflate.c b/deflate.c
index 75db3d0..b65ba25 100644
--- a/deflate.c
+++ b/deflate.c
@@ -47,7 +47,7 @@
47 * 47 *
48 */ 48 */
49 49
50/* $Id: deflate.c,v 1.6 1995/05/01 17:23:57 jloup Exp $ */ 50/* $Id: deflate.c,v 1.7 1995/05/02 13:28:18 jloup Exp $ */
51 51
52#include "deflate.h" 52#include "deflate.h"
53 53
@@ -165,7 +165,7 @@ int deflateInit (strm, level)
165 z_stream *strm; 165 z_stream *strm;
166 int level; 166 int level;
167{ 167{
168 return deflateInit2 (strm, level, DEFLATED, MAX_WBITS, MAX_MEM_LEVEL, 0); 168 return deflateInit2 (strm, level, DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, 0);
169 /* To do: ignore strm->next_in if we use it as window */ 169 /* To do: ignore strm->next_in if we use it as window */
170} 170}
171 171
@@ -344,22 +344,23 @@ int deflate (strm, flush)
344 */ 344 */
345 if (strm->avail_in != 0 || 345 if (strm->avail_in != 0 ||
346 (flush == Z_FINISH && strm->state->status != FINISH_STATE)) { 346 (flush == Z_FINISH && strm->state->status != FINISH_STATE)) {
347 int quit;
347 348
348 if (flush == Z_FINISH) { 349 if (flush == Z_FINISH) {
349 strm->state->status = FINISH_STATE; 350 strm->state->status = FINISH_STATE;
350 } 351 }
351 if (strm->state->level <= 3) { 352 if (strm->state->level <= 3) {
352 if (deflate_fast(strm->state, flush)) return Z_OK; 353 quit = deflate_fast(strm->state, flush);
353 } else { 354 } else {
354 if (deflate_slow(strm->state, flush)) return Z_OK; 355 quit = deflate_slow(strm->state, flush);
355 } 356 }
356 /* ??? remember Z_FULL_FLUSH if we didn't have enough space */
357 if (flush == Z_FULL_FLUSH) { 357 if (flush == Z_FULL_FLUSH) {
358 ct_stored_block(strm->state, (char*)0, 0L, 0); /* special marker */ 358 ct_stored_block(strm->state, (char*)0, 0L, 0); /* special marker */
359 flush_pending(strm); 359 flush_pending(strm);
360 CLEAR_HASH(strm->state); /* forget history */ 360 CLEAR_HASH(strm->state); /* forget history */
361 if (strm->avail_out == 0) return Z_OK; 361 if (strm->avail_out == 0) return Z_OK;
362 } 362 }
363 if (quit) return Z_OK;
363 } 364 }
364 Assert(strm->avail_out > 0, "bug2"); 365 Assert(strm->avail_out > 0, "bug2");
365 366
diff --git a/example.c b/example.c
index c1bac1e..5c34733 100644
--- a/example.c
+++ b/example.c
@@ -3,7 +3,7 @@
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
6/* $Id: example.c,v 1.7 1995/05/01 16:57:22 jloup Exp $ */ 6/* $Id: example.c,v 1.8 1995/05/02 15:52:32 jloup Exp $ */
7 7
8#include <stdio.h> 8#include <stdio.h>
9#include "zlib.h" 9#include "zlib.h"
@@ -12,7 +12,9 @@
12# include <string.h> 12# include <string.h>
13#endif 13#endif
14 14
15#ifndef __GO32__
15extern void exit __P((int)); 16extern void exit __P((int));
17#endif
16 18
17#define BUFLEN 4096 19#define BUFLEN 4096
18 20
@@ -253,7 +255,7 @@ void test_sync(compr)
253 err = inflateEnd(&d_stream); 255 err = inflateEnd(&d_stream);
254 CHECK_ERR(err, "inflateEnd"); 256 CHECK_ERR(err, "inflateEnd");
255 257
256 printf("after inflateSync(): %s\n", uncompr); 258 printf("after inflateSync(): hel%s\n", uncompr);
257} 259}
258 260
259/* =========================================================================== 261/* ===========================================================================
diff --git a/gzio.c b/gzio.c
index 1f5e130..7a3d05a 100644
--- a/gzio.c
+++ b/gzio.c
@@ -3,7 +3,7 @@
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
6/* $Id: gzio.c,v 1.6 1995/04/30 19:52:21 jloup Exp $ */ 6/* $Id: gzio.c,v 1.7 1995/05/02 12:22:08 jloup Exp $ */
7 7
8#include <stdio.h> 8#include <stdio.h>
9 9
@@ -128,7 +128,7 @@ local gzFile gz_open (path, mode, fd)
128 128
129 if (s->mode == 'w') { 129 if (s->mode == 'w') {
130 err = deflateInit2(&(s->stream), Z_DEFAULT_COMPRESSION, 130 err = deflateInit2(&(s->stream), Z_DEFAULT_COMPRESSION,
131 DEFLATED, -MAX_WBITS, MAX_MEM_LEVEL, 0); 131 DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, 0);
132 /* windowBits is passed < 0 to suppress zlib header */ 132 /* windowBits is passed < 0 to suppress zlib header */
133 133
134 s->stream.next_out = s->outbuf = ALLOC(Z_BUFSIZE); 134 s->stream.next_out = s->outbuf = ALLOC(Z_BUFSIZE);
@@ -221,7 +221,7 @@ gzFile gzdopen (fd, mode)
221 char *mode; 221 char *mode;
222{ 222{
223 char name[20]; 223 char name[20];
224 sprintf(name, "_fd:%d_", fd); /* for debugging */ 224 sprintf(name, "<fd:%d>", fd); /* for debugging */
225 225
226 return gz_open (name, mode, fd); 226 return gz_open (name, mode, fd);
227} 227}
diff --git a/inflate.c b/inflate.c
index bed4e54..0b0ee87 100644
--- a/inflate.c
+++ b/inflate.c
@@ -145,7 +145,7 @@ int f;
145 { 145 {
146 case METHOD: 146 case METHOD:
147 NEEDBYTE 147 NEEDBYTE
148 if (((z->state->sub.method = NEXTBYTE) & 0xf != DEFLATED)) 148 if (((z->state->sub.method = NEXTBYTE) & 0xf) != DEFLATED)
149 { 149 {
150 z->state->mode = BAD; 150 z->state->mode = BAD;
151 z->msg = "unknown compression method"; 151 z->msg = "unknown compression method";
@@ -243,7 +243,10 @@ z_stream *z;
243 if (z == Z_NULL || z->state == Z_NULL) 243 if (z == Z_NULL || z->state == Z_NULL)
244 return Z_STREAM_ERROR; 244 return Z_STREAM_ERROR;
245 if (z->state->mode != BAD) 245 if (z->state->mode != BAD)
246 {
247 z->state->mode = BAD;
246 z->state->sub.marker = 0; 248 z->state->sub.marker = 0;
249 }
247 if ((n = z->avail_in) == 0) 250 if ((n = z->avail_in) == 0)
248 return Z_BUF_ERROR; 251 return Z_BUF_ERROR;
249 p = z->next_in; 252 p = z->next_in;
@@ -252,10 +255,12 @@ z_stream *z;
252 /* search */ 255 /* search */
253 while (n && m < 4) 256 while (n && m < 4)
254 { 257 {
255 if (*p == (m < 2 ? 0 : 0xff)) 258 if (*p == (Byte)(m < 2 ? 0 : 0xff))
256 m++; 259 m++;
257 else if (*p || m > 2) 260 else if (*p)
258 m = 0; 261 m = 0;
262 else
263 m = 4 - m;
259 p++, n--; 264 p++, n--;
260 } 265 }
261 266
diff --git a/minigzip.c b/minigzip.c
index d3d2fe9..8f58080 100644
--- a/minigzip.c
+++ b/minigzip.c
@@ -13,12 +13,14 @@
13 * or in pipe mode. 13 * or in pipe mode.
14 */ 14 */
15 15
16/* $Id: minigzip.c,v 1.3 1995/04/29 14:27:21 jloup Exp $ */ 16/* $Id: minigzip.c,v 1.4 1995/05/02 15:54:22 jloup Exp $ */
17 17
18#include <stdio.h> 18#include <stdio.h>
19#include "zlib.h" 19#include "zlib.h"
20 20
21#ifndef __GO32__
21extern void exit __P((int)); 22extern void exit __P((int));
23#endif
22extern int unlink __P((const char *)); 24extern int unlink __P((const char *));
23 25
24#ifdef STDC 26#ifdef STDC
diff --git a/zconf.h b/zconf.h
index 4e05a3e..1abb0ea 100644
--- a/zconf.h
+++ b/zconf.h
@@ -3,7 +3,7 @@
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
6/* $Id: zconf.h,v 1.10 1995/04/30 19:27:14 jloup Exp $ */ 6/* $Id: zconf.h,v 1.11 1995/05/02 13:07:21 jloup Exp $ */
7 7
8#ifndef _ZCONF_H 8#ifndef _ZCONF_H
9#define _ZCONF_H 9#define _ZCONF_H
@@ -32,6 +32,7 @@
32# define STDC 32# define STDC
33#endif 33#endif
34 34
35/* Maximum value for memLevel in deflateInit2 */
35#ifndef MAX_MEM_LEVEL 36#ifndef MAX_MEM_LEVEL
36# ifdef MAXSEG_64K 37# ifdef MAXSEG_64K
37# define MAX_MEM_LEVEL 8 38# define MAX_MEM_LEVEL 8
@@ -40,10 +41,24 @@
40# endif 41# endif
41#endif 42#endif
42 43
44/* Maximum value for windowBits in deflateInit2 and inflateInit2 */
43#ifndef MAX_WBITS 45#ifndef MAX_WBITS
44# define MAX_WBITS 15 /* 32K LZ77 window */ 46# define MAX_WBITS 15 /* 32K LZ77 window */
45#endif 47#endif
46 48
49/* The memory requirements for deflate are (in bytes):
50 1 << (windowBits+2) + 1 << (memLevel+9)
51 that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
52 plus a few kilobytes for small objects. For example, if you want to reduce
53 the default memory requirements from 256K to 128K, compile with
54 make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
55 Of course this will generally degrade compression (there's no free lunch).
56
57 The memory requirements for inflate are (in bytes) 1 << windowBits
58 that is, 32K for windowBits=15 (default value) plus a few kilobytes
59 for small objects.
60*/
61
47 /* Type declarations */ 62 /* Type declarations */
48 63
49#ifndef __P /* function prototypes */ 64#ifndef __P /* function prototypes */
diff --git a/zlib.h b/zlib.h
index e64ab91..1712209 100644
--- a/zlib.h
+++ b/zlib.h
@@ -1,5 +1,5 @@
1/* zlib.h -- interface of the 'zlib' general purpose compression library 1/* zlib.h -- interface of the 'zlib' general purpose compression library
2 version 0.9 April 30th, 1995. 2 version 0.91 May 2nd, 1995.
3 3
4 Copyright (C) 1995 Jean-loup Gailly and Mark Adler 4 Copyright (C) 1995 Jean-loup Gailly and Mark Adler
5 5
@@ -28,7 +28,7 @@
28 28
29#include "zconf.h" 29#include "zconf.h"
30 30
31#define ZLIB_VERSION "0.9" 31#define ZLIB_VERSION "0.91"
32 32
33/* 33/*
34 The 'zlib' compression library provides in-memory compression and 34 The 'zlib' compression library provides in-memory compression and
@@ -335,7 +335,8 @@ extern int deflateInit2 __P((z_stream *strm,
335 The memLevel parameter specifies how much memory should be allocated 335 The memLevel parameter specifies how much memory should be allocated
336 for the internal compression state. memLevel=1 uses minimum memory but 336 for the internal compression state. memLevel=1 uses minimum memory but
337 is slow and reduces compression ratio; memLevel=9 uses maximum memory 337 is slow and reduces compression ratio; memLevel=9 uses maximum memory
338 for optimal speed. The default value is 8. 338 for optimal speed. The default value is 8. See zconf.h for total memory
339 usage as a function of windowBits and memLevel.
339 340
340 The strategy parameter is used to tune the compression algorithm. Use 341 The strategy parameter is used to tune the compression algorithm. Use
341 the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data 342 the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data
diff --git a/zutil.c b/zutil.c
index 4ceb89f..508ad62 100644
--- a/zutil.c
+++ b/zutil.c
@@ -3,13 +3,15 @@
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
6/* $Id: zutil.c,v 1.6 1995/04/29 14:54:02 jloup Exp $ */ 6/* $Id: zutil.c,v 1.7 1995/05/02 15:54:47 jloup Exp $ */
7 7
8#include <stdio.h> 8#include <stdio.h>
9 9
10#include "zutil.h" 10#include "zutil.h"
11 11
12#ifndef __GO32__
12extern void exit __P((int)); 13extern void exit __P((int));
14#endif
13 15
14char *zlib_version = ZLIB_VERSION; 16char *zlib_version = ZLIB_VERSION;
15 17
@@ -55,8 +57,9 @@ void zmemzero(dest, len)
55} 57}
56#endif 58#endif
57 59
58#if defined(MSDOS) && !defined(__SMALL__) && !defined(M_I86SM) 60#if defined(__TURBOC__) && !defined(__SMALL__)
59# ifdef __TURBOC__ 61
62# define MY_ZCALLOC
60 63
61/* Turbo C malloc() does not allow dynamic allocation of 64K bytes 64/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
62 * and farmalloc(64K) returns a pointer with an offset of 8, so we 65 * and farmalloc(64K) returns a pointer with an offset of 8, so we
@@ -124,8 +127,11 @@ void zcfree (voidp opaque, voidp ptr)
124 ptr = opaque; /* just to make some compilers happy */ 127 ptr = opaque; /* just to make some compilers happy */
125 z_error("zcfree: ptr not found"); 128 z_error("zcfree: ptr not found");
126} 129}
130#endif /* __TURBOC__ */
131
132#if defined(M_I86CM) || defined(M_I86LM) /* MSC compact or large model */
127 133
128# else /* MSC */ 134# define MY_ZCALLOC
129 135
130#if (!defined(_MSC_VER) || (_MSC_VER < 600)) 136#if (!defined(_MSC_VER) || (_MSC_VER < 600))
131# define _halloc halloc 137# define _halloc halloc
@@ -144,12 +150,15 @@ void zcfree (voidp opaque, voidp ptr)
144 _hfree(ptr); 150 _hfree(ptr);
145} 151}
146 152
147# endif /* __TURBOC__ ? */ 153#endif /* defined(M_I86CM) || defined(M_I86LM) */
148 154
149#else /* !MSDOS */
150 155
156#ifndef MY_ZCALLOC /* Any system without a special alloc function */
157
158#ifndef __GO32__
151extern voidp calloc __P((uInt items, uInt size)); 159extern voidp calloc __P((uInt items, uInt size));
152extern void free __P((voidp ptr)); 160extern void free __P((voidp ptr));
161#endif
153 162
154voidp zcalloc (opaque, items, size) 163voidp zcalloc (opaque, items, size)
155 voidp opaque; 164 voidp opaque;
@@ -166,4 +175,4 @@ void zcfree (opaque, ptr)
166 free(ptr); 175 free(ptr);
167} 176}
168 177
169#endif /* MSDOS */ 178#endif /* MY_ZCALLOC */
diff --git a/zutil.h b/zutil.h
index a4b00a0..503a445 100644
--- a/zutil.h
+++ b/zutil.h
@@ -8,7 +8,7 @@
8 subject to change. Applications should only use zlib.h. 8 subject to change. Applications should only use zlib.h.
9 */ 9 */
10 10
11/* $Id: zutil.h,v 1.7 1995/04/30 10:55:33 jloup Exp $ */ 11/* $Id: zutil.h,v 1.8 1995/05/02 15:44:46 jloup Exp $ */
12 12
13#ifndef _Z_UTIL_H 13#ifndef _Z_UTIL_H
14#define _Z_UTIL_H 14#define _Z_UTIL_H
@@ -17,6 +17,7 @@
17 17
18#ifdef MSDOS 18#ifdef MSDOS
19# include <stddef.h> 19# include <stddef.h>
20# include <errno.h>
20#else 21#else
21 extern int errno; 22 extern int errno;
22#endif 23#endif
@@ -43,7 +44,14 @@ extern char *z_errmsg[]; /* indexed by 1-zlib_error */
43#define DEFLATED 8 44#define DEFLATED 8
44 45
45#define DEF_WBITS 15 46#define DEF_WBITS 15
46/* default WBITS for decompression. MAX_WBITS is useful for compression only */ 47/* default windowBits for decompression. MAX_WBITS is for compression only */
48
49#if MAX_MEM_LEVEL >= 8
50# define DEF_MEM_LEVEL 8
51#else
52# define DEF_MEM_LEVEL MAX_MEM_LEVEL
53#endif
54/* default memLevel */
47 55
48#define STORED_BLOCK 0 56#define STORED_BLOCK 0
49#define STATIC_TREES 1 57#define STATIC_TREES 1