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

Function test_deflate

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

=========================================================================== * Test deflate() with small buffers */

(compr, comprLen)

Source from the content-addressed store, hash-verified

223 * Test deflate() with small buffers
224 */
225void test_deflate(compr, comprLen)
226 Byte *compr;
227 uLong comprLen;
228{
229 z_stream c_stream; /* compression stream */
230 int err;
231 uLong len = (uLong)strlen(hello)+1;
232
233 c_stream.zalloc = zalloc;
234 c_stream.zfree = zfree;
235 c_stream.opaque = (voidpf)0;
236
237 err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
238 CHECK_ERR(err, "deflateInit");
239
240 c_stream.next_in = (z_const unsigned char *)hello;
241 c_stream.next_out = compr;
242
243 while (c_stream.total_in != len && c_stream.total_out < comprLen) {
244 c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */
245 err = deflate(&c_stream, Z_NO_FLUSH);
246 CHECK_ERR(err, "deflate");
247 }
248 /* Finish the stream, still forcing small buffers: */
249 for (;;) {
250 c_stream.avail_out = 1;
251 err = deflate(&c_stream, Z_FINISH);
252 if (err == Z_STREAM_END) break;
253 CHECK_ERR(err, "deflate");
254 }
255
256 err = deflateEnd(&c_stream);
257 CHECK_ERR(err, "deflateEnd");
258}
259
260/* ===========================================================================
261 * Test inflate() with small buffers

Callers 1

mainFunction · 0.70

Calls 2

deflateFunction · 0.85
deflateEndFunction · 0.85

Tested by

no test coverage detected