Thank you.
Of the gzip, zlib, and raw deflate formats, only gzip puts the
uncompressed length in the stream. For gzip , the last four bytes is
the length of the uncompressed data in little-endian order. However
there are significant caveats on that. First, since it is four bytes,
it is actually the length modulo 2^32, for those cases where the
uncompressed length is >= 4 GB. Second, a gzip stream may consist of
multiple gzip streams, in which case the last four bytes only gives
you the length of the last piece. Third, some gzip streams have junk
on the end, in which case you'll get something other than the length
in the last four bytes.
So not only can you not find the uncompressed length for zlib and raw
deflate, you also cannot find it reliably for gzip.
I recommend that you not use approaches that require that you know the
length. zlib provides the inflateInit2(), inflate(), and
inflateReset(), and inflateEnd() functions that allow you to
decompress in pieces, with repeated uses of inflate(). You should use
those. Read the documentation in zlib.h.
Mark