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

Function test_dict_deflate

freebsd/contrib/zlib/test/example.c:457–489  ·  view source on GitHub ↗

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

(compr, comprLen)

Source from the content-addressed store, hash-verified

455 * Test deflate() with preset dictionary
456 */
457void test_dict_deflate(compr, comprLen)
458 Byte *compr;
459 uLong comprLen;
460{
461 z_stream c_stream; /* compression stream */
462 int err;
463
464 c_stream.zalloc = zalloc;
465 c_stream.zfree = zfree;
466 c_stream.opaque = (voidpf)0;
467
468 err = deflateInit(&c_stream, Z_BEST_COMPRESSION);
469 CHECK_ERR(err, "deflateInit");
470
471 err = deflateSetDictionary(&c_stream,
472 (const Bytef*)dictionary, (int)sizeof(dictionary));
473 CHECK_ERR(err, "deflateSetDictionary");
474
475 dictId = c_stream.adler;
476 c_stream.next_out = compr;
477 c_stream.avail_out = (uInt)comprLen;
478
479 c_stream.next_in = (z_const unsigned char *)hello;
480 c_stream.avail_in = (uInt)strlen(hello)+1;
481
482 err = deflate(&c_stream, Z_FINISH);
483 if (err != Z_STREAM_END) {
484 fprintf(stderr, "deflate should report Z_STREAM_END\n");
485 exit(1);
486 }
487 err = deflateEnd(&c_stream);
488 CHECK_ERR(err, "deflateEnd");
489}
490
491/* ===========================================================================
492 * 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