"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "zlib/zlib/test/example.c" between
muscle7.61.zip and muscle7.62.zip

About: MUSCLE (Multi User Server Client Linking Environment) is a messaging server and networking API. The included server program ("muscled") lets its clients message each other, and/or store information in its serverside hierarchical database.

example.c  (muscle7.61):example.c  (muscle7.62)
/* example.c -- usage example of the zlib compression library /* example.c -- usage example of the zlib compression library
* Copyright (C) 1995-2006, 2011 Jean-loup Gailly. * Copyright (C) 1995-2006, 2011, 2016 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* @(#) $Id$ */ /* @(#) $Id$ */
#include "zlib.h" #include "zlib.h"
#include <stdio.h> #include <stdio.h>
#ifdef STDC #ifdef STDC
# include <string.h> # include <string.h>
skipping to change at line 29 skipping to change at line 29
# define TESTFILE "foo.gz" # define TESTFILE "foo.gz"
#endif #endif
#define CHECK_ERR(err, msg) { \ #define CHECK_ERR(err, msg) { \
if (err != Z_OK) { \ if (err != Z_OK) { \
fprintf(stderr, "%s error: %d\n", msg, err); \ fprintf(stderr, "%s error: %d\n", msg, err); \
exit(1); \ exit(1); \
} \ } \
} }
z_const char hello[] = "hello, hello!"; static z_const char hello[] = "hello, hello!";
/* "hello world" would be more standard, but the repeated "hello" /* "hello world" would be more standard, but the repeated "hello"
* stresses the compression code better, sorry... * stresses the compression code better, sorry...
*/ */
const char dictionary[] = "hello"; static const char dictionary[] = "hello";
uLong dictId; /* Adler32 value of the dictionary */ static uLong dictId; /* Adler32 value of the dictionary */
void test_deflate OF((Byte *compr, uLong comprLen)); void test_deflate OF((Byte *compr, uLong comprLen));
void test_inflate OF((Byte *compr, uLong comprLen, void test_inflate OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen)); Byte *uncompr, uLong uncomprLen));
void test_large_deflate OF((Byte *compr, uLong comprLen, void test_large_deflate OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen)); Byte *uncompr, uLong uncomprLen));
void test_large_inflate OF((Byte *compr, uLong comprLen, void test_large_inflate OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen)); Byte *uncompr, uLong uncomprLen));
void test_flush OF((Byte *compr, uLong *comprLen)); void test_flush OF((Byte *compr, uLong *comprLen));
void test_sync OF((Byte *compr, uLong comprLen, void test_sync OF((Byte *compr, uLong comprLen,
skipping to change at line 61 skipping to change at line 61
#ifdef Z_SOLO #ifdef Z_SOLO
void *myalloc OF((void *, unsigned, unsigned)); void *myalloc OF((void *, unsigned, unsigned));
void myfree OF((void *, void *)); void myfree OF((void *, void *));
void *myalloc(q, n, m) void *myalloc(q, n, m)
void *q; void *q;
unsigned n, m; unsigned n, m;
{ {
q = Z_NULL; (void)q;
return calloc(n, m); return calloc(n, m);
} }
void myfree(void *q, void *p) void myfree(void *q, void *p)
{ {
q = Z_NULL; (void)q;
free(p); free(p);
} }
static alloc_func zalloc = myalloc; static alloc_func zalloc = myalloc;
static free_func zfree = myfree; static free_func zfree = myfree;
#else /* !Z_SOLO */ #else /* !Z_SOLO */
static alloc_func zalloc = (alloc_func)0; static alloc_func zalloc = (alloc_func)0;
static free_func zfree = (free_func)0; static free_func zfree = (free_func)0;
skipping to change at line 434 skipping to change at line 434
d_stream.next_in = compr; d_stream.next_in = compr;
d_stream.avail_in = 2; /* just read the zlib header */ d_stream.avail_in = 2; /* just read the zlib header */
err = inflateInit(&d_stream); err = inflateInit(&d_stream);
CHECK_ERR(err, "inflateInit"); CHECK_ERR(err, "inflateInit");
d_stream.next_out = uncompr; d_stream.next_out = uncompr;
d_stream.avail_out = (uInt)uncomprLen; d_stream.avail_out = (uInt)uncomprLen;
inflate(&d_stream, Z_NO_FLUSH); err = inflate(&d_stream, Z_NO_FLUSH);
CHECK_ERR(err, "inflate"); CHECK_ERR(err, "inflate");
d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */ d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */
err = inflateSync(&d_stream); /* but skip the damaged part */ err = inflateSync(&d_stream); /* but skip the damaged part */
CHECK_ERR(err, "inflateSync"); CHECK_ERR(err, "inflateSync");
err = inflate(&d_stream, Z_FINISH); err = inflate(&d_stream, Z_FINISH);
if (err != Z_DATA_ERROR) { if (err != Z_DATA_ERROR) {
fprintf(stderr, "inflate should report DATA_ERROR\n"); fprintf(stderr, "inflate should report DATA_ERROR\n");
/* Because of incorrect adler32 */ /* Because of incorrect adler32 */
skipping to change at line 575 skipping to change at line 575
uncompr = (Byte*)calloc((uInt)uncomprLen, 1); uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
/* compr and uncompr are cleared to avoid reading uninitialized /* compr and uncompr are cleared to avoid reading uninitialized
* data and to ensure that uncompr compresses well. * data and to ensure that uncompr compresses well.
*/ */
if (compr == Z_NULL || uncompr == Z_NULL) { if (compr == Z_NULL || uncompr == Z_NULL) {
printf("out of memory\n"); printf("out of memory\n");
exit(1); exit(1);
} }
#ifdef Z_SOLO #ifdef Z_SOLO
argc = strlen(argv[0]); (void)argc;
(void)argv;
#else #else
test_compress(compr, comprLen, uncompr, uncomprLen); test_compress(compr, comprLen, uncompr, uncomprLen);
test_gzio((argc > 1 ? argv[1] : TESTFILE), test_gzio((argc > 1 ? argv[1] : TESTFILE),
uncompr, uncomprLen); uncompr, uncomprLen);
#endif #endif
test_deflate(compr, comprLen); test_deflate(compr, comprLen);
test_inflate(compr, comprLen, uncompr, uncomprLen); test_inflate(compr, comprLen, uncompr, uncomprLen);
 End of changes. 7 change blocks. 
8 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)