MCPcopy Create free account
hub / github.com/F-Stack/f-stack / main

Function main

freebsd/contrib/zstd/zlibWrapper/examples/example.c:570–629  ·  view source on GitHub ↗
(argc, argv)

Source from the content-addressed store, hash-verified

568 */
569
570int main(argc, argv)
571 int argc;
572 char *argv[];
573{
574 Byte *compr, *uncompr;
575 uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
576 uLong uncomprLen = comprLen;
577 static const char* myVersion = ZLIB_VERSION;
578
579 if (zlibVersion()[0] != myVersion[0]) {
580 fprintf(stderr, "incompatible zlib version\n");
581 exit(1);
582
583 } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) {
584 fprintf(stderr, "warning: different zlib version\n");
585 }
586
587 printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n",
588 ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags());
589 if (ZWRAP_isUsingZSTDcompression()) printf("zstd version %s\n", zstdVersion());
590
591 compr = (Byte*)calloc((uInt)comprLen, 1);
592 uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
593 /* compr and uncompr are cleared to avoid reading uninitialized
594 * data and to ensure that uncompr compresses well.
595 */
596 if (compr == Z_NULL || uncompr == Z_NULL) {
597 printf("out of memory\n");
598 exit(1);
599 }
600
601#ifdef Z_SOLO
602 argc = strlen(argv[0]);
603#else
604 test_compress(compr, comprLen, uncompr, uncomprLen);
605
606 test_gzio((argc > 1 ? argv[1] : TESTFILE),
607 uncompr, uncomprLen);
608#endif
609
610 test_deflate(compr, comprLen);
611 test_inflate(compr, comprLen, uncompr, uncomprLen);
612
613 test_large_deflate(compr, comprLen, uncompr, uncomprLen);
614 test_large_inflate(compr, comprLen, uncompr, uncomprLen);
615
616 if (!ZWRAP_isUsingZSTDcompression()) {
617 test_flush(compr, &comprLen);
618 test_sync(compr, comprLen, uncompr, uncomprLen);
619 }
620 comprLen = uncomprLen;
621
622 test_dict_deflate(compr, comprLen);
623 test_dict_inflate(compr, comprLen, uncompr, uncomprLen);
624
625 free(compr);
626 free(uncompr);
627

Callers

nothing calls this directly

Calls 15

zlibVersionFunction · 0.85
strcmpFunction · 0.85
zlibCompileFlagsFunction · 0.85
zstdVersionFunction · 0.85
callocFunction · 0.85
test_compressFunction · 0.70
test_gzioFunction · 0.70
test_deflateFunction · 0.70
test_inflateFunction · 0.70
test_large_deflateFunction · 0.70
test_large_inflateFunction · 0.70

Tested by

no test coverage detected