Cause of z_buf_error in zlib's uncompress Function

Source: Internet
Author: User
Tags uncompress

Function prototype:

Int uncompress (bytef * DEST, ulogfn * destlen, const bytef * Source, ulong sourcelen );


Function Description: uncompress Function will Source Extract the buffer content Dest Buffer zone. Sourcelen Yes Source The buffer size (in bytes ). Note that the second parameter of the Function Destlen Is an address transfer call. When calling a function, destlen Indicates Dest Buffer size, Dest The buffer must be sufficient to store the extracted data. During decompression, you need to know in advance how large the compressed data will be. This requires that the size of the original data (that is, the size of the extracted data) be saved before compression ). This is not Zlib The function of the function library requires additional work. When the function exits, Destlen Is the actual size of the extracted data.

UncompressIf yes, returnZ_ OK ; If there is not enough memory, returnZ_mem_error; If the output buffer is not large enough, returnZ_buf_error. If the input data is incorrect, z_data_error is returned.

If the data size after decompression is known, assign destlen to the data size after decompression. If you do not know the data size after decompression, destlen should be large enough!


Cause of z_buf_error:

DestThe buffer size is insufficient.

DestThe buffer size is brought in by the second destlen parameter. If the buffer type is not ulofgns, type conversion may occur due to different types, resulting in a smaller value for uncompress and z_buf_error.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.