diff options
Diffstat (limited to 'example.c')
-rw-r--r-- | example.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -3,7 +3,7 @@ | |||
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ | 4 | */ |
5 | 5 | ||
6 | /* $Id: example.c,v 1.13 1996/01/30 21:59:13 me Exp $ */ | 6 | /* $Id: example.c,v 1.16 1996/05/23 17:11:28 me Exp $ */ |
7 | 7 | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include "zlib.h" | 9 | #include "zlib.h" |
@@ -462,16 +462,19 @@ int main(argc, argv) | |||
462 | uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ | 462 | uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ |
463 | uLong uncomprLen = comprLen; | 463 | uLong uncomprLen = comprLen; |
464 | 464 | ||
465 | if (zlib_version[0] != ZLIB_VERSION[0]) { | 465 | if (zlibVersion()[0] != ZLIB_VERSION[0]) { |
466 | fprintf(stderr, "incompatible zlib version\n"); | 466 | fprintf(stderr, "incompatible zlib version\n"); |
467 | exit(1); | 467 | exit(1); |
468 | 468 | ||
469 | } else if (strcmp(zlib_version, ZLIB_VERSION) != 0) { | 469 | } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) { |
470 | fprintf(stderr, "warning: different zlib version\n"); | 470 | fprintf(stderr, "warning: different zlib version\n"); |
471 | } | 471 | } |
472 | 472 | ||
473 | compr = (Byte*)malloc((uInt)comprLen); | 473 | compr = (Byte*)calloc((uInt)comprLen, 1); |
474 | uncompr = (Byte*)calloc((uInt)uncomprLen, 1); /* must be cleared */ | 474 | uncompr = (Byte*)calloc((uInt)uncomprLen, 1); |
475 | /* compr and uncompr are cleared to avoid reading uninitialized | ||
476 | * data and to ensure that uncompr compresses well. | ||
477 | */ | ||
475 | if (compr == Z_NULL || uncompr == Z_NULL) { | 478 | if (compr == Z_NULL || uncompr == Z_NULL) { |
476 | printf("out of memory\n"); | 479 | printf("out of memory\n"); |
477 | exit(1); | 480 | exit(1); |