22 int ZEXPORT
compress2 (Bytef *dest, uLongf *destLen,
const Bytef *source, uLong sourceLen,
int level)
27 stream.next_in = (z_const Bytef *)source;
28 stream.avail_in = (uInt)sourceLen;
31 if ((uLong)stream.avail_in != sourceLen)
return Z_BUF_ERROR;
33 stream.next_out = dest;
34 stream.avail_out = (uInt)*destLen;
35 if ((uLong)stream.avail_out != *destLen)
return Z_BUF_ERROR;
37 stream.zalloc = (alloc_func)0;
38 stream.zfree = (free_func)0;
39 stream.opaque = (voidpf)0;
41 err = deflateInit(&stream, level);
42 if (err != Z_OK)
return err;
44 err =
deflate(&stream, Z_FINISH);
45 if (err != Z_STREAM_END) {
47 return err == Z_OK ? Z_BUF_ERROR : err;
49 *destLen = stream.total_out;
57 int ZEXPORT
compress (Bytef *dest, uLongf *destLen,
const Bytef *source, uLong sourceLen)
59 return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
68 return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
69 (sourceLen >> 25) + 13;
int ZEXPORT deflateEnd(z_streamp strm)
uLong ZEXPORT compressBound(uLong sourceLen)
int ZEXPORT deflate(z_streamp strm, int flush)
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)