aboutsummaryrefslogtreecommitdiff
path: root/zutil.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2023-04-14 01:42:03 -0700
committerMark Adler <madler@alumni.caltech.edu>2023-04-15 21:17:31 -0700
commite9d5486e6635141f589e110fd789648aa08e9544 (patch)
treea78b9ccd92b05af7cd5776b688d9c3eb3a81a40a /zutil.c
parent5799c14c8526bf1aaa130c021982f831d155b46d (diff)
downloadzlib-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.c60
1 files changed, 16 insertions, 44 deletions
diff --git a/zutil.c b/zutil.c
index 9543ae8..b1c5d2d 100644
--- a/zutil.c
+++ b/zutil.c
@@ -24,13 +24,11 @@ z_const char * const z_errmsg[10] = {
24}; 24};
25 25
26 26
27const char * ZEXPORT zlibVersion() 27const char * ZEXPORT zlibVersion(void) {
28{
29 return ZLIB_VERSION; 28 return ZLIB_VERSION;
30} 29}
31 30
32uLong ZEXPORT zlibCompileFlags() 31uLong 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
122int ZLIB_INTERNAL z_verbose = verbose; 120int ZLIB_INTERNAL z_verbose = verbose;
123 121
124void ZLIB_INTERNAL z_error(m) 122void 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 */
135const char * ZEXPORT zError(err) 131const 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
151void ZLIB_INTERNAL zmemcpy(dest, source, len) 145void 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
162int ZLIB_INTERNAL zmemcmp(s1, s2, len) 152int 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
175void ZLIB_INTERNAL zmemzero(dest, len) 161void 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
219voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) 202voidpf 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
245void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) 227void 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
282voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) 263voidpf 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
288void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) 268void 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
302extern voidp malloc OF((uInt size)); 281extern voidp malloc(uInt size);
303extern voidp calloc OF((uInt items, uInt size)); 282extern voidp calloc(uInt items, uInt size);
304extern void free OF((voidpf ptr)); 283extern void free(voidpf ptr);
305#endif 284#endif
306 285
307voidpf ZLIB_INTERNAL zcalloc(opaque, items, size) 286voidpf 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
317void ZLIB_INTERNAL zcfree(opaque, ptr) 292void 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}