17950657.patch revision 1379
1450N/A--- a/common/rdr/ZlibOutStream.h Thu Dec 12 14:31:34 2013
1450N/A+++ b/common/rdr/ZlibOutStream.h Thu Dec 12 14:31:41 2013
1450N/A@@ -46,7 +46,6 @@
1450N/A private:
1450N/A
1450N/A int overrun(int itemSize, int nItems);
1450N/A- void checkCompressionLevel();
1450N/A
1450N/A OutStream* underlying;
1450N/A int compressionLevel;
1450N/A--- a/common/rdr//ZlibOutStream.cxx Thu Dec 12 14:28:19 2013
1450N/A+++ b/common/rdr/ZlibOutStream.cxx Thu Dec 12 14:31:28 2013
1450N/A@@ -68,6 +68,11 @@
1450N/A level = -1; // Z_DEFAULT_COMPRESSION
1450N/A
1450N/A newLevel = level;
1450N/A+ if (newLevel != compressionLevel) {
1450N/A+ if (deflateParams (zs, newLevel, Z_DEFAULT_STRATEGY) != Z_OK)
1450N/A+ throw Exception("ZlibOutStream: deflateParams failed");
1450N/A+ compressionLevel = newLevel;
1450N/A+ }
1450N/A }
1450N/A
1450N/A int ZlibOutStream::length()
1450N/A@@ -94,11 +99,9 @@
1450N/A
1450N/A // fprintf(stderr,"zos flush: calling deflate, avail_in %d, avail_out %d\n",
1450N/A // zs->avail_in,zs->avail_out);
1450N/A- checkCompressionLevel();
1450N/A- if (zs->avail_in != 0) {
1450N/A- int rc = deflate(zs, Z_SYNC_FLUSH);
1450N/A- if (rc != Z_OK) throw Exception("ZlibOutStream: deflate failed");
1450N/A- }
1450N/A+ int rc = deflate(zs, Z_SYNC_FLUSH);
1450N/A+ if (rc != Z_OK)
1450N/A+ throw Exception("ZlibOutStream: deflate failed");
1450N/A
1450N/A // fprintf(stderr,"zos flush: after deflate: %d bytes\n",
1450N/A // zs->next_out-underlying->getptr());
1450N/A@@ -133,11 +136,9 @@
1450N/A // fprintf(stderr,"zos overrun: calling deflate, avail_in %d, avail_out %d\n",
1450N/A // zs->avail_in,zs->avail_out);
1450N/A
1450N/A- checkCompressionLevel();
1450N/A- if (zs->avail_in != 0) {
1450N/A- int rc = deflate(zs, 0);
1450N/A- if (rc != Z_OK) throw Exception("ZlibOutStream: deflate failed");
1450N/A- }
1450N/A+ int rc = deflate(zs, Z_SYNC_FLUSH);
1450N/A+ if (rc != Z_OK)
1450N/A+ throw Exception("ZlibOutStream: deflate failed");
1450N/A
1450N/A // fprintf(stderr,"zos overrun: after deflate: %d bytes\n",
1450N/A // zs->next_out-underlying->getptr());
1450N/A@@ -164,25 +165,4 @@
1450N/A nItems = (end - ptr) / itemSize;
1450N/A
1450N/A return nItems;
1450N/A-}
1450N/A-
1450N/A-void ZlibOutStream::checkCompressionLevel()
1450N/A-{
1450N/A- if (newLevel != compressionLevel) {
1450N/A-
1450N/A- // This is a horrible hack, but after many hours of trying, I couldn't find
1450N/A- // a better way to make this class work properly with both Zlib 1.2.3 and
1450N/A- // 1.2.5. 1.2.3 does a Z_PARTIAL_FLUSH in the body of deflateParams() if
1450N/A- // the compression level has changed, and 1.2.5 does a Z_BLOCK flush.
1450N/A-
1450N/A- if (newBehavior) {
1450N/A- int rc = deflate(zs, Z_SYNC_FLUSH);
1450N/A- if (rc != Z_OK) throw Exception("ZlibOutStream: deflate failed");
1450N/A- }
1450N/A-
1450N/A- if (deflateParams (zs, newLevel, Z_DEFAULT_STRATEGY) != Z_OK) {
1450N/A- throw Exception("ZlibOutStream: deflateParams failed");
1450N/A- }
1450N/A- compressionLevel = newLevel;
1450N/A- }
1450N/A }
1450N/A