Fix compression bug where incompressible files weren't transmitted correctly.
authorPaul Mackerras <paulus@samba.org>
Wed, 2 Oct 1996 04:20:22 +0000 (04:20 +0000)
committerPaul Mackerras <paulus@samba.org>
Wed, 2 Oct 1996 04:20:22 +0000 (04:20 +0000)
lib/zlib.c
lib/zlib.h
token.c

index f26071e..9d96513 100644 (file)
@@ -7,7 +7,6 @@
  *
  * Changes that have been made include:
  * - changed functions not used outside this file to "local"
  *
  * Changes that have been made include:
  * - changed functions not used outside this file to "local"
- * - added minCompression parameter to deflateInit2
  * - added Z_PACKET_FLUSH (see zlib.h for details)
  * - added inflateIncomp
  *
  * - added Z_PACKET_FLUSH (see zlib.h for details)
  * - added inflateIncomp
  *
@@ -211,7 +210,6 @@ typedef struct deflate_state {
     int   noheader;      /* suppress zlib header and adler32 */
     Byte  data_type;     /* UNKNOWN, BINARY or ASCII */
     Byte  method;        /* STORED (for zip only) or DEFLATED */
     int   noheader;      /* suppress zlib header and adler32 */
     Byte  data_type;     /* UNKNOWN, BINARY or ASCII */
     Byte  method;        /* STORED (for zip only) or DEFLATED */
-    int          minCompr;      /* min size decrease for Z_FLUSH_NOSTORE */
 
                 /* used by deflate.c: */
 
 
                 /* used by deflate.c: */
 
@@ -568,21 +566,18 @@ int deflateInit (strm, level)
     z_stream *strm;
     int level;
 {
     z_stream *strm;
     int level;
 {
-    return deflateInit2 (strm, level, DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
-                        0, 0);
+    return deflateInit2 (strm, level, DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, 0);
     /* To do: ignore strm->next_in if we use it as window */
 }
 
 /* ========================================================================= */
     /* To do: ignore strm->next_in if we use it as window */
 }
 
 /* ========================================================================= */
-int deflateInit2 (strm, level, method, windowBits, memLevel,
-                 strategy, minCompression)
+int deflateInit2 (strm, level, method, windowBits, memLevel, strategy)
     z_stream *strm;
     int  level;
     int  method;
     int  windowBits;
     int  memLevel;
     int  strategy;
     z_stream *strm;
     int  level;
     int  method;
     int  windowBits;
     int  memLevel;
     int  strategy;
-    int  minCompression;
 {
     deflate_state *s;
     int noheader = 0;
 {
     deflate_state *s;
     int noheader = 0;
@@ -642,7 +637,6 @@ int deflateInit2 (strm, level, method, windowBits, memLevel,
     s->level = level;
     s->strategy = strategy;
     s->method = (Byte)method;
     s->level = level;
     s->strategy = strategy;
     s->method = (Byte)method;
-    s->minCompr = minCompression;
     s->blocks_in_packet = 0;
 
     return deflateReset(strm);
     s->blocks_in_packet = 0;
 
     return deflateReset(strm);
@@ -2337,17 +2331,6 @@ local ulg ct_flush_block(s, buf, stored_len, flush)
     } else
 #endif /* STORED_FILE_OK */
 
     } else
 #endif /* STORED_FILE_OK */
 
-    /* For Z_PACKET_FLUSH, if we don't achieve the required minimum
-     * compression, and this block contains all the data since the last
-     * time we used Z_PACKET_FLUSH, then just omit this block completely
-     * from the output.
-     */
-    if (flush == Z_PACKET_FLUSH && s->blocks_in_packet == 1
-       && opt_lenb > stored_len - s->minCompr) {
-       s->blocks_in_packet = 0;
-       /* output nothing */
-    } else
-
 #ifdef FORCE_STORED
     if (buf != (char*)0) /* force stored block */
 #else
 #ifdef FORCE_STORED
     if (buf != (char*)0) /* force stored block */
 #else
index 2018f70..e3413d6 100644 (file)
@@ -444,8 +444,7 @@ extern int deflateInit2 OF((z_stream *strm,
                             int  method,
                             int  windowBits,
                             int  memLevel,
                             int  method,
                             int  windowBits,
                             int  memLevel,
-                            int  strategy,
-                           int  minCompression));
+                            int  strategy));
 /*   
      This is another version of deflateInit with more compression options. The
    fields next_in, zalloc and zfree must be initialized before by the caller.
 /*   
      This is another version of deflateInit with more compression options. The
    fields next_in, zalloc and zfree must be initialized before by the caller.
diff --git a/token.c b/token.c
index 5056569..9d3bccd 100644 (file)
--- a/token.c
+++ b/token.c
@@ -116,7 +116,7 @@ send_deflated_token(int f, int token,
            tx_strm.zalloc = z_alloc;
            tx_strm.zfree = z_free;
            if (deflateInit2(&tx_strm, Z_DEFAULT_COMPRESSION, 8,
            tx_strm.zalloc = z_alloc;
            tx_strm.zfree = z_free;
            if (deflateInit2(&tx_strm, Z_DEFAULT_COMPRESSION, 8,
-                            -15, 8, Z_DEFAULT_STRATEGY, -4) != Z_OK) {
+                            -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
                fprintf(FERROR, "compression init failed\n");
                exit_cleanup(1);
            }
                fprintf(FERROR, "compression init failed\n");
                exit_cleanup(1);
            }