aboutsummaryrefslogtreecommitdiff
path: root/test/example.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 /test/example.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 'test/example.c')
-rw-r--r--test/example.c93
1 files changed, 18 insertions, 75 deletions
diff --git a/test/example.c b/test/example.c
index 1470bc8..1c755bc 100644
--- a/test/example.c
+++ b/test/example.c
@@ -34,37 +34,14 @@ static z_const char hello[] = "hello, hello!";
34static const char dictionary[] = "hello"; 34static const char dictionary[] = "hello";
35static uLong dictId; /* Adler32 value of the dictionary */ 35static uLong dictId; /* Adler32 value of the dictionary */
36 36
37void test_deflate OF((Byte *compr, uLong comprLen));
38void test_inflate OF((Byte *compr, uLong comprLen,
39 Byte *uncompr, uLong uncomprLen));
40void test_large_deflate OF((Byte *compr, uLong comprLen,
41 Byte *uncompr, uLong uncomprLen));
42void test_large_inflate OF((Byte *compr, uLong comprLen,
43 Byte *uncompr, uLong uncomprLen));
44void test_flush OF((Byte *compr, uLong *comprLen));
45void test_sync OF((Byte *compr, uLong comprLen,
46 Byte *uncompr, uLong uncomprLen));
47void test_dict_deflate OF((Byte *compr, uLong comprLen));
48void test_dict_inflate OF((Byte *compr, uLong comprLen,
49 Byte *uncompr, uLong uncomprLen));
50int main OF((int argc, char *argv[]));
51
52
53#ifdef Z_SOLO 37#ifdef Z_SOLO
54 38
55void *myalloc OF((void *, unsigned, unsigned)); 39void *myalloc(void *q, unsigned n, unsigned m) {
56void myfree OF((void *, void *));
57
58void *myalloc(q, n, m)
59 void *q;
60 unsigned n, m;
61{
62 (void)q; 40 (void)q;
63 return calloc(n, m); 41 return calloc(n, m);
64} 42}
65 43
66void myfree(void *q, void *p) 44void myfree(void *q, void *p) {
67{
68 (void)q; 45 (void)q;
69 free(p); 46 free(p);
70} 47}
@@ -77,18 +54,11 @@ static free_func zfree = myfree;
77static alloc_func zalloc = (alloc_func)0; 54static alloc_func zalloc = (alloc_func)0;
78static free_func zfree = (free_func)0; 55static free_func zfree = (free_func)0;
79 56
80void test_compress OF((Byte *compr, uLong comprLen,
81 Byte *uncompr, uLong uncomprLen));
82void test_gzio OF((const char *fname,
83 Byte *uncompr, uLong uncomprLen));
84
85/* =========================================================================== 57/* ===========================================================================
86 * Test compress() and uncompress() 58 * Test compress() and uncompress()
87 */ 59 */
88void test_compress(compr, comprLen, uncompr, uncomprLen) 60void test_compress(Byte *compr, uLong comprLen, Byte *uncompr,
89 Byte *compr, *uncompr; 61 uLong uncomprLen) {
90 uLong comprLen, uncomprLen;
91{
92 int err; 62 int err;
93 uLong len = (uLong)strlen(hello)+1; 63 uLong len = (uLong)strlen(hello)+1;
94 64
@@ -111,11 +81,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen)
111/* =========================================================================== 81/* ===========================================================================
112 * Test read/write of .gz files 82 * Test read/write of .gz files
113 */ 83 */
114void test_gzio(fname, uncompr, uncomprLen) 84void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) {
115 const char *fname; /* compressed file name */
116 Byte *uncompr;
117 uLong uncomprLen;
118{
119#ifdef NO_GZCOMPRESS 85#ifdef NO_GZCOMPRESS
120 fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); 86 fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
121#else 87#else
@@ -197,10 +163,7 @@ void test_gzio(fname, uncompr, uncomprLen)
197/* =========================================================================== 163/* ===========================================================================
198 * Test deflate() with small buffers 164 * Test deflate() with small buffers
199 */ 165 */
200void test_deflate(compr, comprLen) 166void test_deflate(Byte *compr, uLong comprLen) {
201 Byte *compr;
202 uLong comprLen;
203{
204 z_stream c_stream; /* compression stream */ 167 z_stream c_stream; /* compression stream */
205 int err; 168 int err;
206 uLong len = (uLong)strlen(hello)+1; 169 uLong len = (uLong)strlen(hello)+1;
@@ -235,10 +198,8 @@ void test_deflate(compr, comprLen)
235/* =========================================================================== 198/* ===========================================================================
236 * Test inflate() with small buffers 199 * Test inflate() with small buffers
237 */ 200 */
238void test_inflate(compr, comprLen, uncompr, uncomprLen) 201void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
239 Byte *compr, *uncompr; 202 uLong uncomprLen) {
240 uLong comprLen, uncomprLen;
241{
242 int err; 203 int err;
243 z_stream d_stream; /* decompression stream */ 204 z_stream d_stream; /* decompression stream */
244 205
@@ -276,10 +237,8 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen)
276/* =========================================================================== 237/* ===========================================================================
277 * Test deflate() with large buffers and dynamic change of compression level 238 * Test deflate() with large buffers and dynamic change of compression level
278 */ 239 */
279void test_large_deflate(compr, comprLen, uncompr, uncomprLen) 240void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr,
280 Byte *compr, *uncompr; 241 uLong uncomprLen) {
281 uLong comprLen, uncomprLen;
282{
283 z_stream c_stream; /* compression stream */ 242 z_stream c_stream; /* compression stream */
284 int err; 243 int err;
285 244
@@ -331,10 +290,8 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
331/* =========================================================================== 290/* ===========================================================================
332 * Test inflate() with large buffers 291 * Test inflate() with large buffers
333 */ 292 */
334void test_large_inflate(compr, comprLen, uncompr, uncomprLen) 293void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
335 Byte *compr, *uncompr; 294 uLong uncomprLen) {
336 uLong comprLen, uncomprLen;
337{
338 int err; 295 int err;
339 z_stream d_stream; /* decompression stream */ 296 z_stream d_stream; /* decompression stream */
340 297
@@ -372,10 +329,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
372/* =========================================================================== 329/* ===========================================================================
373 * Test deflate() with full flush 330 * Test deflate() with full flush
374 */ 331 */
375void test_flush(compr, comprLen) 332void test_flush(Byte *compr, uLong *comprLen) {
376 Byte *compr;
377 uLong *comprLen;
378{
379 z_stream c_stream; /* compression stream */ 333 z_stream c_stream; /* compression stream */
380 int err; 334 int err;
381 uInt len = (uInt)strlen(hello)+1; 335 uInt len = (uInt)strlen(hello)+1;
@@ -410,10 +364,7 @@ void test_flush(compr, comprLen)
410/* =========================================================================== 364/* ===========================================================================
411 * Test inflateSync() 365 * Test inflateSync()
412 */ 366 */
413void test_sync(compr, comprLen, uncompr, uncomprLen) 367void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) {
414 Byte *compr, *uncompr;
415 uLong comprLen, uncomprLen;
416{
417 int err; 368 int err;
418 z_stream d_stream; /* decompression stream */ 369 z_stream d_stream; /* decompression stream */
419 370
@@ -453,10 +404,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen)
453/* =========================================================================== 404/* ===========================================================================
454 * Test deflate() with preset dictionary 405 * Test deflate() with preset dictionary
455 */ 406 */
456void test_dict_deflate(compr, comprLen) 407void test_dict_deflate(Byte *compr, uLong comprLen) {
457 Byte *compr;
458 uLong comprLen;
459{
460 z_stream c_stream; /* compression stream */ 408 z_stream c_stream; /* compression stream */
461 int err; 409 int err;
462 410
@@ -490,10 +438,8 @@ void test_dict_deflate(compr, comprLen)
490/* =========================================================================== 438/* ===========================================================================
491 * Test inflate() with a preset dictionary 439 * Test inflate() with a preset dictionary
492 */ 440 */
493void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) 441void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
494 Byte *compr, *uncompr; 442 uLong uncomprLen) {
495 uLong comprLen, uncomprLen;
496{
497 int err; 443 int err;
498 z_stream d_stream; /* decompression stream */ 444 z_stream d_stream; /* decompression stream */
499 445
@@ -541,10 +487,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
541 * Usage: example [output.gz [input.gz]] 487 * Usage: example [output.gz [input.gz]]
542 */ 488 */
543 489
544int main(argc, argv) 490int main(int argc, char *argv[]) {
545 int argc;
546 char *argv[];
547{
548 Byte *compr, *uncompr; 491 Byte *compr, *uncompr;
549 uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ 492 uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
550 uLong uncomprLen = comprLen; 493 uLong uncomprLen = comprLen;