diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2023-04-14 01:42:03 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2023-04-15 21:17:31 -0700 |
commit | e9d5486e6635141f589e110fd789648aa08e9544 (patch) | |
tree | a78b9ccd92b05af7cd5776b688d9c3eb3a81a40a /zutil.c | |
parent | 5799c14c8526bf1aaa130c021982f831d155b46d (diff) | |
download | zlib-e9d5486e6635141f589e110fd789648aa08e9544.tar.gz zlib-e9d5486e6635141f589e110fd789648aa08e9544.tar.bz2 zlib-e9d5486e6635141f589e110fd789648aa08e9544.zip |
Remove K&R function definitions from zlib.
C2X has removed K&R definitions from the C function syntax.
Though the standard has not yet been approved, some high-profile
compilers are now issuing warnings when such definitions are
encountered.
Diffstat (limited to 'zutil.c')
-rw-r--r-- | zutil.c | 60 |
1 files changed, 16 insertions, 44 deletions
@@ -24,13 +24,11 @@ z_const char * const z_errmsg[10] = { | |||
24 | }; | 24 | }; |
25 | 25 | ||
26 | 26 | ||
27 | const char * ZEXPORT zlibVersion() | 27 | const char * ZEXPORT zlibVersion(void) { |
28 | { | ||
29 | return ZLIB_VERSION; | 28 | return ZLIB_VERSION; |
30 | } | 29 | } |
31 | 30 | ||
32 | uLong ZEXPORT zlibCompileFlags() | 31 | uLong ZEXPORT zlibCompileFlags(void) { |
33 | { | ||
34 | uLong flags; | 32 | uLong flags; |
35 | 33 | ||
36 | flags = 0; | 34 | flags = 0; |
@@ -121,9 +119,7 @@ uLong ZEXPORT zlibCompileFlags() | |||
121 | # endif | 119 | # endif |
122 | int ZLIB_INTERNAL z_verbose = verbose; | 120 | int ZLIB_INTERNAL z_verbose = verbose; |
123 | 121 | ||
124 | void ZLIB_INTERNAL z_error(m) | 122 | void ZLIB_INTERNAL z_error(char *m) { |
125 | char *m; | ||
126 | { | ||
127 | fprintf(stderr, "%s\n", m); | 123 | fprintf(stderr, "%s\n", m); |
128 | exit(1); | 124 | exit(1); |
129 | } | 125 | } |
@@ -132,9 +128,7 @@ void ZLIB_INTERNAL z_error(m) | |||
132 | /* exported to allow conversion of error code to string for compress() and | 128 | /* exported to allow conversion of error code to string for compress() and |
133 | * uncompress() | 129 | * uncompress() |
134 | */ | 130 | */ |
135 | const char * ZEXPORT zError(err) | 131 | const char * ZEXPORT zError(int err) { |
136 | int err; | ||
137 | { | ||
138 | return ERR_MSG(err); | 132 | return ERR_MSG(err); |
139 | } | 133 | } |
140 | 134 | ||
@@ -148,22 +142,14 @@ const char * ZEXPORT zError(err) | |||
148 | 142 | ||
149 | #ifndef HAVE_MEMCPY | 143 | #ifndef HAVE_MEMCPY |
150 | 144 | ||
151 | void ZLIB_INTERNAL zmemcpy(dest, source, len) | 145 | void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) { |
152 | Bytef* dest; | ||
153 | const Bytef* source; | ||
154 | uInt len; | ||
155 | { | ||
156 | if (len == 0) return; | 146 | if (len == 0) return; |
157 | do { | 147 | do { |
158 | *dest++ = *source++; /* ??? to be unrolled */ | 148 | *dest++ = *source++; /* ??? to be unrolled */ |
159 | } while (--len != 0); | 149 | } while (--len != 0); |
160 | } | 150 | } |
161 | 151 | ||
162 | int ZLIB_INTERNAL zmemcmp(s1, s2, len) | 152 | int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) { |
163 | const Bytef* s1; | ||
164 | const Bytef* s2; | ||
165 | uInt len; | ||
166 | { | ||
167 | uInt j; | 153 | uInt j; |
168 | 154 | ||
169 | for (j = 0; j < len; j++) { | 155 | for (j = 0; j < len; j++) { |
@@ -172,10 +158,7 @@ int ZLIB_INTERNAL zmemcmp(s1, s2, len) | |||
172 | return 0; | 158 | return 0; |
173 | } | 159 | } |
174 | 160 | ||
175 | void ZLIB_INTERNAL zmemzero(dest, len) | 161 | void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) { |
176 | Bytef* dest; | ||
177 | uInt len; | ||
178 | { | ||
179 | if (len == 0) return; | 162 | if (len == 0) return; |
180 | do { | 163 | do { |
181 | *dest++ = 0; /* ??? to be unrolled */ | 164 | *dest++ = 0; /* ??? to be unrolled */ |
@@ -216,8 +199,7 @@ local ptr_table table[MAX_PTR]; | |||
216 | * a protected system like OS/2. Use Microsoft C instead. | 199 | * a protected system like OS/2. Use Microsoft C instead. |
217 | */ | 200 | */ |
218 | 201 | ||
219 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) | 202 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { |
220 | { | ||
221 | voidpf buf; | 203 | voidpf buf; |
222 | ulg bsize = (ulg)items*size; | 204 | ulg bsize = (ulg)items*size; |
223 | 205 | ||
@@ -242,8 +224,7 @@ voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) | |||
242 | return buf; | 224 | return buf; |
243 | } | 225 | } |
244 | 226 | ||
245 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) | 227 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { |
246 | { | ||
247 | int n; | 228 | int n; |
248 | 229 | ||
249 | (void)opaque; | 230 | (void)opaque; |
@@ -279,14 +260,12 @@ void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) | |||
279 | # define _hfree hfree | 260 | # define _hfree hfree |
280 | #endif | 261 | #endif |
281 | 262 | ||
282 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) | 263 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) { |
283 | { | ||
284 | (void)opaque; | 264 | (void)opaque; |
285 | return _halloc((long)items, size); | 265 | return _halloc((long)items, size); |
286 | } | 266 | } |
287 | 267 | ||
288 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) | 268 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { |
289 | { | ||
290 | (void)opaque; | 269 | (void)opaque; |
291 | _hfree(ptr); | 270 | _hfree(ptr); |
292 | } | 271 | } |
@@ -299,25 +278,18 @@ void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) | |||
299 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ | 278 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ |
300 | 279 | ||
301 | #ifndef STDC | 280 | #ifndef STDC |
302 | extern voidp malloc OF((uInt size)); | 281 | extern voidp malloc(uInt size); |
303 | extern voidp calloc OF((uInt items, uInt size)); | 282 | extern voidp calloc(uInt items, uInt size); |
304 | extern void free OF((voidpf ptr)); | 283 | extern void free(voidpf ptr); |
305 | #endif | 284 | #endif |
306 | 285 | ||
307 | voidpf ZLIB_INTERNAL zcalloc(opaque, items, size) | 286 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { |
308 | voidpf opaque; | ||
309 | unsigned items; | ||
310 | unsigned size; | ||
311 | { | ||
312 | (void)opaque; | 287 | (void)opaque; |
313 | return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : | 288 | return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : |
314 | (voidpf)calloc(items, size); | 289 | (voidpf)calloc(items, size); |
315 | } | 290 | } |
316 | 291 | ||
317 | void ZLIB_INTERNAL zcfree(opaque, ptr) | 292 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { |
318 | voidpf opaque; | ||
319 | voidpf ptr; | ||
320 | { | ||
321 | (void)opaque; | 293 | (void)opaque; |
322 | free(ptr); | 294 | free(ptr); |
323 | } | 295 | } |