zlib

how to inflate zlib sub-chunk not having previous chunks but having z_stream which deflated it?


I deflate data and send output chunks into server. In case of network error I need to start fresh zlib stream (the server expects this), but because I still hold last deflated chunk (without origin data) and I don't want to lose this data I would like to inflate this chunk and deflate it into new zlib stream.

Is it possible to inflate such chunk not having all previous chunks but having z_stream object which deflated it?


Solution

  • If I understand your question, then no. If you have a final chunk of deflate data, you cannot decompress it without having all of the previous deflate data to refer to. The way LZ77 works is by referring to matching strings in the preceding uncompressed data.