summaryrefslogtreecommitdiff
path: root/example.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-09-09 23:15:17 -0700
committerMark Adler <madler@alumni.caltech.edu>2011-09-09 23:15:17 -0700
commite26a448e9673d67dc2866e11a48d24fc352e5f80 (patch)
treea2dc10debfd34979dde501afbf1cce6a6c3cbcb7 /example.c
parent423eb40306489f9c88f7dba32c2f69179166730b (diff)
zlib 1.0.2
Diffstat (limited to 'example.c')
-rw-r--r--example.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/example.c b/example.c
index 175fa81..5e4dc6d 100644
--- a/example.c
+++ b/example.c
@@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-/* $Id: example.c,v 1.13 1996/01/30 21:59:13 me Exp $ */
+/* $Id: example.c,v 1.16 1996/05/23 17:11:28 me Exp $ */
#include <stdio.h>
#include "zlib.h"
@@ -462,16 +462,19 @@ int main(argc, argv)
uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
uLong uncomprLen = comprLen;
- if (zlib_version[0] != ZLIB_VERSION[0]) {
+ if (zlibVersion()[0] != ZLIB_VERSION[0]) {
fprintf(stderr, "incompatible zlib version\n");
exit(1);
- } else if (strcmp(zlib_version, ZLIB_VERSION) != 0) {
+ } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) {
fprintf(stderr, "warning: different zlib version\n");
}
- compr = (Byte*)malloc((uInt)comprLen);
- uncompr = (Byte*)calloc((uInt)uncomprLen, 1); /* must be cleared */
+ compr = (Byte*)calloc((uInt)comprLen, 1);
+ uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
+ /* compr and uncompr are cleared to avoid reading uninitialized
+ * data and to ensure that uncompr compresses well.
+ */
if (compr == Z_NULL || uncompr == Z_NULL) {
printf("out of memory\n");
exit(1);