diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:14:39 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:14:39 -0700 |
commit | 423eb40306489f9c88f7dba32c2f69179166730b (patch) | |
tree | b5a83b0b1e52bbe0de973dcbc7ec008c1d7cf7d9 /zutil.c | |
parent | 8a2acbffc86012de3523ecf91db2c4ea1b1c4ea2 (diff) | |
download | zlib-423eb40306489f9c88f7dba32c2f69179166730b.tar.gz zlib-423eb40306489f9c88f7dba32c2f69179166730b.tar.bz2 zlib-423eb40306489f9c88f7dba32c2f69179166730b.zip |
zlib 1.0.1v1.0.1
Diffstat (limited to 'zutil.c')
-rw-r--r-- | zutil.c | 44 |
1 files changed, 21 insertions, 23 deletions
@@ -1,9 +1,9 @@ | |||
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 | ||
6 | /* $Id: zutil.c,v 1.8 1995/05/03 17:27:12 jloup Exp $ */ | 6 | /* $Id: zutil.c,v 1.12 1996/01/30 21:59:29 me Exp $ */ |
7 | 7 | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | 9 | ||
@@ -15,16 +15,18 @@ struct internal_state {int dummy;}; /* for buggy compilers */ | |||
15 | extern void exit OF((int)); | 15 | extern void exit OF((int)); |
16 | #endif | 16 | #endif |
17 | 17 | ||
18 | char *zlib_version = ZLIB_VERSION; | 18 | const char *zlib_version = ZLIB_VERSION; |
19 | 19 | ||
20 | char *z_errmsg[] = { | 20 | const 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 | ||
@@ -60,9 +62,9 @@ void zmemzero(dest, len) | |||
60 | #endif | 62 | #endif |
61 | 63 | ||
62 | #ifdef __TURBOC__ | 64 | #ifdef __TURBOC__ |
63 | #if !defined(__SMALL__) && !defined(__MEDIUM__) && !defined(__32BIT__) | 65 | #if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__) |
64 | /* Small and medium model are for now limited to near allocation with | 66 | /* Small and medium model in Turbo C are for now limited to near allocation |
65 | * reduced MAX_WBITS and MAX_MEM_LEVEL | 67 | * with reduced MAX_WBITS and MAX_MEM_LEVEL |
66 | */ | 68 | */ |
67 | # define MY_ZCALLOC | 69 | # define MY_ZCALLOC |
68 | 70 | ||
@@ -100,9 +102,6 @@ voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) | |||
100 | */ | 102 | */ |
101 | if (bsize < 65520L) { | 103 | if (bsize < 65520L) { |
102 | buf = farmalloc(bsize); | 104 | buf = farmalloc(bsize); |
103 | #ifdef DEBUG | ||
104 | zmemzero(buf, (uInt)bsize); | ||
105 | #endif | ||
106 | if (*(ush*)&buf != 0) return buf; | 105 | if (*(ush*)&buf != 0) return buf; |
107 | } else { | 106 | } else { |
108 | buf = farmalloc(bsize + 16L); | 107 | buf = farmalloc(bsize + 16L); |
@@ -114,10 +113,6 @@ voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) | |||
114 | *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; | 113 | *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; |
115 | *(ush*)&buf = 0; | 114 | *(ush*)&buf = 0; |
116 | table[next_ptr++].new_ptr = buf; | 115 | table[next_ptr++].new_ptr = buf; |
117 | #ifdef DEBUG | ||
118 | zmemzero(buf, (uInt)65535); | ||
119 | ((uch*)buf)[65535] = 0; | ||
120 | #endif | ||
121 | return buf; | 116 | return buf; |
122 | } | 117 | } |
123 | 118 | ||
@@ -146,7 +141,8 @@ void zcfree (voidpf opaque, voidpf ptr) | |||
146 | #endif /* __TURBOC__ */ | 141 | #endif /* __TURBOC__ */ |
147 | 142 | ||
148 | 143 | ||
149 | #ifdef M_I86 /* Microsoft C */ | 144 | #if defined(M_I86) && !(defined(__WATCOMC__) && defined(__386__)) |
145 | /* Microsoft C */ | ||
150 | 146 | ||
151 | # define MY_ZCALLOC | 147 | # define MY_ZCALLOC |
152 | 148 | ||
@@ -182,6 +178,7 @@ voidpf zcalloc (opaque, items, size) | |||
182 | unsigned items; | 178 | unsigned items; |
183 | unsigned size; | 179 | unsigned size; |
184 | { | 180 | { |
181 | if (opaque) items += size - size; /* make compiler happy */ | ||
185 | return (voidpf)calloc(items, size); | 182 | return (voidpf)calloc(items, size); |
186 | } | 183 | } |
187 | 184 | ||
@@ -190,6 +187,7 @@ void zcfree (opaque, ptr) | |||
190 | voidpf ptr; | 187 | voidpf ptr; |
191 | { | 188 | { |
192 | free(ptr); | 189 | free(ptr); |
190 | if (opaque) return; /* make compiler happy */ | ||
193 | } | 191 | } |
194 | 192 | ||
195 | #endif /* MY_ZCALLOC */ | 193 | #endif /* MY_ZCALLOC */ |