diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2015-10-04 11:45:00 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2015-10-04 11:48:42 -0700 |
commit | 8f1b3744e52b2adb6475c3cd7a07ff9331e9c2fa (patch) | |
tree | 5dbe4bda0efa9738baa35412f738c4ebf1f6317c /zutil.c | |
parent | f77c9823441ba169b3877976cb40b72731aa7980 (diff) | |
download | zlib-8f1b3744e52b2adb6475c3cd7a07ff9331e9c2fa.tar.gz zlib-8f1b3744e52b2adb6475c3cd7a07ff9331e9c2fa.tar.bz2 zlib-8f1b3744e52b2adb6475c3cd7a07ff9331e9c2fa.zip |
Use a consistent and more modern approach to not use a parameter.
A remarkably creative and diverse set of approaches to letting the
compiler know that opaque was being used when it wasn't is changed
by this commit to the more standard (void)opaque.
Diffstat (limited to 'zutil.c')
-rw-r--r-- | zutil.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -219,9 +219,11 @@ local ptr_table table[MAX_PTR]; | |||
219 | 219 | ||
220 | voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) | 220 | voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) |
221 | { | 221 | { |
222 | voidpf buf = opaque; /* just to make some compilers happy */ | 222 | voidpf buf; |
223 | ulg bsize = (ulg)items*size; | 223 | ulg bsize = (ulg)items*size; |
224 | 224 | ||
225 | (void)opaque; | ||
226 | |||
225 | /* If we allocate less than 65520 bytes, we assume that farmalloc | 227 | /* If we allocate less than 65520 bytes, we assume that farmalloc |
226 | * will return a usable pointer which doesn't have to be normalized. | 228 | * will return a usable pointer which doesn't have to be normalized. |
227 | */ | 229 | */ |
@@ -244,6 +246,9 @@ voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) | |||
244 | void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) | 246 | void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) |
245 | { | 247 | { |
246 | int n; | 248 | int n; |
249 | |||
250 | (void)opaque; | ||
251 | |||
247 | if (*(ush*)&ptr != 0) { /* object < 64K */ | 252 | if (*(ush*)&ptr != 0) { /* object < 64K */ |
248 | farfree(ptr); | 253 | farfree(ptr); |
249 | return; | 254 | return; |
@@ -259,7 +264,6 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) | |||
259 | next_ptr--; | 264 | next_ptr--; |
260 | return; | 265 | return; |
261 | } | 266 | } |
262 | ptr = opaque; /* just to make some compilers happy */ | ||
263 | Assert(0, "zcfree: ptr not found"); | 267 | Assert(0, "zcfree: ptr not found"); |
264 | } | 268 | } |
265 | 269 | ||
@@ -278,13 +282,13 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) | |||
278 | 282 | ||
279 | voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) | 283 | voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) |
280 | { | 284 | { |
281 | if (opaque) opaque = 0; /* to make compiler happy */ | 285 | (void)opaque; |
282 | return _halloc((long)items, size); | 286 | return _halloc((long)items, size); |
283 | } | 287 | } |
284 | 288 | ||
285 | void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) | 289 | void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) |
286 | { | 290 | { |
287 | if (opaque) opaque = 0; /* to make compiler happy */ | 291 | (void)opaque; |
288 | _hfree(ptr); | 292 | _hfree(ptr); |
289 | } | 293 | } |
290 | 294 | ||
@@ -306,7 +310,7 @@ voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) | |||
306 | unsigned items; | 310 | unsigned items; |
307 | unsigned size; | 311 | unsigned size; |
308 | { | 312 | { |
309 | if (opaque) items += size - size; /* make compiler happy */ | 313 | (void)opaque; |
310 | return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : | 314 | return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : |
311 | (voidpf)calloc(items, size); | 315 | (voidpf)calloc(items, size); |
312 | } | 316 | } |
@@ -315,8 +319,8 @@ void ZLIB_INTERNAL zcfree (opaque, ptr) | |||
315 | voidpf opaque; | 319 | voidpf opaque; |
316 | voidpf ptr; | 320 | voidpf ptr; |
317 | { | 321 | { |
322 | (void)opaque; | ||
318 | free(ptr); | 323 | free(ptr); |
319 | if (opaque) return; /* make compiler happy */ | ||
320 | } | 324 | } |
321 | 325 | ||
322 | #endif /* MY_ZCALLOC */ | 326 | #endif /* MY_ZCALLOC */ |