summaryrefslogtreecommitdiff
path: root/zutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'zutil.c')
-rw-r--r--zutil.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/zutil.c b/zutil.c
index f7bd6e5..97e74ea 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-1996 Jean-loup Gailly. 2 * Copyright (C) 1995 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
@@ -15,18 +15,16 @@ struct internal_state {int dummy;}; /* for buggy compilers */
15extern void exit OF((int)); 15extern void exit OF((int));
16#endif 16#endif
17 17
18const char *zlib_version = ZLIB_VERSION; 18char *zlib_version = ZLIB_VERSION;
19 19
20const char *z_errmsg[10] = { 20char *z_errmsg[] = {
21"need dictionary", /* Z_NEED_DICT 2 */ 21"stream end", /* Z_STREAM_END 1 */
22"stream end", /* Z_STREAM_END 1 */ 22"", /* Z_OK 0 */
23"", /* Z_OK 0 */ 23"file error", /* Z_ERRNO (-1) */
24"file error", /* Z_ERRNO (-1) */ 24"stream error", /* Z_STREAM_ERROR (-2) */
25"stream error", /* Z_STREAM_ERROR (-2) */ 25"data error", /* Z_DATA_ERROR (-3) */
26"data error", /* Z_DATA_ERROR (-3) */ 26"insufficient memory", /* Z_MEM_ERROR (-4) */
27"insufficient memory", /* Z_MEM_ERROR (-4) */ 27"buffer error", /* Z_BUF_ERROR (-5) */
28"buffer error", /* Z_BUF_ERROR (-5) */
29"incompatible version",/* Z_VERSION_ERROR (-6) */
30""}; 28""};
31 29
32 30
@@ -62,9 +60,9 @@ void zmemzero(dest, len)
62#endif 60#endif
63 61
64#ifdef __TURBOC__ 62#ifdef __TURBOC__
65#if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__) 63#if !defined(__SMALL__) && !defined(__MEDIUM__) && !defined(__32BIT__)
66/* Small and medium model in Turbo C are for now limited to near allocation 64/* Small and medium model are for now limited to near allocation with
67 * with reduced MAX_WBITS and MAX_MEM_LEVEL 65 * reduced MAX_WBITS and MAX_MEM_LEVEL
68 */ 66 */
69# define MY_ZCALLOC 67# define MY_ZCALLOC
70 68
@@ -102,6 +100,9 @@ voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
102 */ 100 */
103 if (bsize < 65520L) { 101 if (bsize < 65520L) {
104 buf = farmalloc(bsize); 102 buf = farmalloc(bsize);
103#ifdef DEBUG
104 zmemzero(buf, (uInt)bsize);
105#endif
105 if (*(ush*)&buf != 0) return buf; 106 if (*(ush*)&buf != 0) return buf;
106 } else { 107 } else {
107 buf = farmalloc(bsize + 16L); 108 buf = farmalloc(bsize + 16L);
@@ -113,6 +114,10 @@ voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
113 *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; 114 *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
114 *(ush*)&buf = 0; 115 *(ush*)&buf = 0;
115 table[next_ptr++].new_ptr = buf; 116 table[next_ptr++].new_ptr = buf;
117#ifdef DEBUG
118 zmemzero(buf, (uInt)65535);
119 ((uch*)buf)[65535] = 0;
120#endif
116 return buf; 121 return buf;
117} 122}
118 123
@@ -141,8 +146,7 @@ void zcfree (voidpf opaque, voidpf ptr)
141#endif /* __TURBOC__ */ 146#endif /* __TURBOC__ */
142 147
143 148
144#if defined(M_I86) && !(defined(__WATCOMC__) && defined(__386__)) 149#ifdef M_I86 /* Microsoft C */
145/* Microsoft C */
146 150
147# define MY_ZCALLOC 151# define MY_ZCALLOC
148 152
@@ -178,7 +182,6 @@ voidpf zcalloc (opaque, items, size)
178 unsigned items; 182 unsigned items;
179 unsigned size; 183 unsigned size;
180{ 184{
181 if (opaque) opaque = 0; /* to make compiler happy */
182 return (voidpf)calloc(items, size); 185 return (voidpf)calloc(items, size);
183} 186}
184 187
@@ -186,7 +189,6 @@ void zcfree (opaque, ptr)
186 voidpf opaque; 189 voidpf opaque;
187 voidpf ptr; 190 voidpf ptr;
188{ 191{
189 if (opaque) opaque = 0; /* to make compiler happy */
190 free(ptr); 192 free(ptr);
191} 193}
192 194