- if(uncompress(dest, &destlen, source, len) == Z_OK) {
- return destlen;
+ if(stream.next_in) {
+ inflateReset(&stream);
+ } else {
+ inflateInit(&stream);
+ }
+
+ stream.next_in = source;
+ stream.avail_in = len;
+ stream.next_out = dest;
+ stream.avail_out = destlen;
+ stream.total_out = 0;
+
+ if(inflate(&stream, Z_FINISH) == Z_STREAM_END) {
+ return stream.total_out;