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.