Hello! I have just take a look at Примеры сжатия данных в C/C++ при помощи zlib | Записки программиста and think that maybe you can implement decompressing with data chunks instead of guessing what would be total size… Moreover, this algorithm should answer how many bytes are processed to output.