C++学习(四八二)zlib的inflate

本文详细介绍了zlib库中inflate函数的工作原理、初始化过程和使用方法,包括inflateInit的功能、inflate的解压行为及flush参数的影响。通过解压流程,展示了如何进行数据解压,并解释了不同flush参数的含义及其对解压过程的影响。
摘要由CSDN通过智能技术生成

zlib 1.2.11 Manual icon-default.png?t=M1L8https://www.zlib.net/manual.html

原理:


ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));

Initializes the internal stream state for decompression. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by the caller. In the current version of inflate, the provided input is not read or consumed. The allocation of a sliding window will be deferred to the first call of inflate (if the decompression does not complete on the first call). If zalloc and zfree are set to Z_NULL, inflateInit updates them to use default allocation functions.

inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the version assumed by the caller, or Z_STREAM_ERROR if the parameters are invalid, such as a null pointer to the structure. msg is set to null if there is no error message. inflateInit does not perform any decompression. Actual decompression will be done by inflate(). So next_in, and avail_in, next_out, and avail_out are unused and unchanged. The current implementation of inflateInit() does not process any header information—that is deferred until inflate() is called.


ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));

inflate decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值