summaryrefslogtreecommitdiff
path: root/zutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'zutil.c')
-rw-r--r--zutil.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/zutil.c b/zutil.c
index 67c4e54..f7bd6e5 100644
--- a/zutil.c
+++ b/zutil.c
@@ -1,5 +1,5 @@
1/* zutil.c -- target dependent utility functions for the compression library 1/* zutil.c -- target dependent utility functions for the compression library
2 * Copyright (C) 1995 Jean-loup Gailly. 2 * Copyright (C) 1995-1996 Jean-loup Gailly.
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
@@ -11,20 +11,22 @@
11 11
12struct internal_state {int dummy;}; /* for buggy compilers */ 12struct internal_state {int dummy;}; /* for buggy compilers */
13 13
14#ifndef __GO32__ 14#ifndef STDC
15extern void exit OF((int)); 15extern void exit OF((int));
16#endif 16#endif
17 17
18char *zlib_version = ZLIB_VERSION; 18const char *zlib_version = ZLIB_VERSION;
19 19
20char *z_errmsg[] = { 20const char *z_errmsg[10] = {
21"stream end", /* Z_STREAM_END 1 */ 21"need dictionary", /* Z_NEED_DICT 2 */
22"", /* Z_OK 0 */ 22"stream end", /* Z_STREAM_END 1 */
23"file error", /* Z_ERRNO (-1) */ 23"", /* Z_OK 0 */
24"stream error", /* Z_STREAM_ERROR (-2) */ 24"file error", /* Z_ERRNO (-1) */
25"data error", /* Z_DATA_ERROR (-3) */ 25"stream error", /* Z_STREAM_ERROR (-2) */
26"insufficient memory", /* Z_MEM_ERROR (-4) */ 26"data error", /* Z_DATA_ERROR (-3) */
27"buffer error", /* Z_BUF_ERROR (-5) */ 27"insufficient memory", /* Z_MEM_ERROR (-4) */
28"buffer error", /* Z_BUF_ERROR (-5) */
29"incompatible version",/* Z_VERSION_ERROR (-6) */
28""}; 30""};
29 31
30 32
@@ -59,9 +61,10 @@ void zmemzero(dest, len)
59} 61}
60#endif 62#endif
61 63
62#if defined( __TURBOC__) && !defined(__SMALL__) && !defined(__MEDIUM__) 64#ifdef __TURBOC__
63/* Small and medium model are for now limited to near allocation with 65#if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__)
64 * reduced MAX_WBITS and MAX_MEM_LEVEL 66/* Small and medium model in Turbo C are for now limited to near allocation
67 * with reduced MAX_WBITS and MAX_MEM_LEVEL
65 */ 68 */
66# define MY_ZCALLOC 69# define MY_ZCALLOC
67 70
@@ -94,7 +97,10 @@ voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
94 voidpf buf = opaque; /* just to make some compilers happy */ 97 voidpf buf = opaque; /* just to make some compilers happy */
95 ulg bsize = (ulg)items*size; 98 ulg bsize = (ulg)items*size;
96 99
97 if (bsize < 65536L) { 100 /* If we allocate less than 65520 bytes, we assume that farmalloc
101 * will return a usable pointer which doesn't have to be normalized.
102 */
103 if (bsize < 65520L) {
98 buf = farmalloc(bsize); 104 buf = farmalloc(bsize);
99 if (*(ush*)&buf != 0) return buf; 105 if (*(ush*)&buf != 0) return buf;
100 } else { 106 } else {
@@ -131,9 +137,11 @@ void zcfree (voidpf opaque, voidpf ptr)
131 ptr = opaque; /* just to make some compilers happy */ 137 ptr = opaque; /* just to make some compilers happy */
132 z_error("zcfree: ptr not found"); 138 z_error("zcfree: ptr not found");
133} 139}
140#endif
134#endif /* __TURBOC__ */ 141#endif /* __TURBOC__ */
135 142
136#if defined(M_I86SM)||defined(M_I86MM)||defined(M_I86CM)||defined(M_I86LM) 143
144#if defined(M_I86) && !(defined(__WATCOMC__) && defined(__386__))
137/* Microsoft C */ 145/* Microsoft C */
138 146
139# define MY_ZCALLOC 147# define MY_ZCALLOC
@@ -160,7 +168,7 @@ void zcfree (voidpf opaque, voidpf ptr)
160 168
161#ifndef MY_ZCALLOC /* Any system without a special alloc function */ 169#ifndef MY_ZCALLOC /* Any system without a special alloc function */
162 170
163#ifndef __GO32__ 171#ifndef STDC
164extern voidp calloc OF((uInt items, uInt size)); 172extern voidp calloc OF((uInt items, uInt size));
165extern void free OF((voidpf ptr)); 173extern void free OF((voidpf ptr));
166#endif 174#endif
@@ -170,6 +178,7 @@ voidpf zcalloc (opaque, items, size)
170 unsigned items; 178 unsigned items;
171 unsigned size; 179 unsigned size;
172{ 180{
181 if (opaque) opaque = 0; /* to make compiler happy */
173 return (voidpf)calloc(items, size); 182 return (voidpf)calloc(items, size);
174} 183}
175 184
@@ -177,6 +186,7 @@ void zcfree (opaque, ptr)
177 voidpf opaque; 186 voidpf opaque;
178 voidpf ptr; 187 voidpf ptr;
179{ 188{
189 if (opaque) opaque = 0; /* to make compiler happy */
180 free(ptr); 190 free(ptr);
181} 191}
182 192