For reasons, I am currently trying to make use of minizs
tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags);
on an ESP32. As stated in the thin documentation available I initialize the pOut_buf_start
to have size TINFL_LZ_DICT_SIZE
. Since I am decoding a network stream, the size of the decompressed data is potentially infinite, but I feed a maximum of 512 bytes at once in the input buffer to avoid getting too many decompressed data at once.
Everything works fine until I reach the point where pOut_buf_next
gets close to the end of the output buffer:
TINFL_STATUS_HAS_MORE_OUTPUT
sooner or later (which, as I understand, leaves me in a unrecoverable state?)pOut_buf_next = pOut_buf_start
and pOut_buf_size=TINFL_LZ_DICT_SIZE
), but that seems to corrupt the output of my next tinfl_decompress callHow do I handle this best/correct?
Is TINFL_STATUS_HAS_MORE_OUTPUT
really unrecoverable? At what point am I allowed to wrap the output buffer?
Turns out my buffer handling was wrong. TINFL_STATUS_HAS_MORE_OUTPUT
seems to be the correct point in time to wrap the buffer.