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

Function test_dict_deflate

freebsd/contrib/zstd/zlibWrapper/examples/example.c:482–514  ·  view source on GitHub ↗

=========================================================================== * Test deflate() with preset dictionary */

(compr, comprLen)

Source from the content-addressed store, hash-verified

480 * Test deflate() with preset dictionary
481 */
482void test_dict_deflate(compr, comprLen)
483 Byte *compr;
484 uLong comprLen;
485{
486 z_stream c_stream; /* compression stream */
487 int err;
488
489 c_stream.zalloc = zalloc;
490 c_stream.zfree = zfree;
491 c_stream.opaque = (voidpf)0;
492
493 err = deflateInit(&c_stream, Z_BEST_COMPRESSION);
494 CHECK_ERR(err, "deflateInit");
495
496 err = deflateSetDictionary(&c_stream,
497 (const Bytef*)dictionary, (int)sizeof(dictionary));
498 CHECK_ERR(err, "deflateSetDictionary");
499
500 dictId = c_stream.adler;
501 c_stream.next_out = compr;
502 c_stream.avail_out = (uInt)comprLen;
503
504 c_stream.next_in = (z_const unsigned char *)hello;
505 c_stream.avail_in = (uInt)strlen(hello)+1;
506
507 err = deflate(&c_stream, Z_FINISH);
508 if (err != Z_STREAM_END) {
509 fprintf(stderr, "deflate should report Z_STREAM_END\n");
510 exit(1);
511 }
512 err = deflateEnd(&c_stream);
513 CHECK_ERR(err, "deflateEnd");
514}
515
516/* ===========================================================================
517 * Test inflate() with a preset dictionary

Callers 1

mainFunction · 0.70

Calls 3

deflateSetDictionaryFunction · 0.85
deflateFunction · 0.85
deflateEndFunction · 0.85

Tested by

no test coverage detected