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

Function test_sync

freebsd/contrib/zstd/zlibWrapper/examples/example_original.c:430–469  ·  view source on GitHub ↗

=========================================================================== * Test inflateSync() */

(compr, comprLen, uncompr, uncomprLen)

Source from the content-addressed store, hash-verified

428 * Test inflateSync()
429 */
430void test_sync(compr, comprLen, uncompr, uncomprLen)
431 Byte *compr, *uncompr;
432 uLong comprLen, uncomprLen;
433{
434 int err;
435 z_stream d_stream; /* decompression stream */
436
437 strcpy((char*)uncompr, "garbage");
438
439 d_stream.zalloc = zalloc;
440 d_stream.zfree = zfree;
441 d_stream.opaque = (voidpf)0;
442
443 d_stream.next_in = compr;
444 d_stream.avail_in = 2; /* just read the zlib header */
445
446 err = inflateInit(&d_stream);
447 CHECK_ERR(err, "inflateInit");
448
449 d_stream.next_out = uncompr;
450 d_stream.avail_out = (uInt)uncomprLen;
451
452 inflate(&d_stream, Z_NO_FLUSH);
453 CHECK_ERR(err, "inflate");
454
455 d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */
456 err = inflateSync(&d_stream); /* but skip the damaged part */
457 CHECK_ERR(err, "inflateSync");
458
459 err = inflate(&d_stream, Z_FINISH);
460 if (err != Z_DATA_ERROR) {
461 fprintf(stderr, "inflate should report DATA_ERROR\n");
462 /* Because of incorrect adler32 */
463 exit(1);
464 }
465 err = inflateEnd(&d_stream);
466 CHECK_ERR(err, "inflateEnd");
467
468 printf("after inflateSync(): hel%s\n", (char *)uncompr);
469}
470
471/* ===========================================================================
472 * Test deflate() with preset dictionary

Callers 1

mainFunction · 0.70

Calls 1

printfFunction · 0.50

Tested by

no test coverage detected