]> git.lizzy.rs Git - zlib.git/commitdiff
Fix gzwrite.c to accommodate reduced memory zlib compilation.
authorMark Adler <madler@alumni.caltech.edu>
Thu, 8 Dec 2011 18:16:31 +0000 (10:16 -0800)
committerMark Adler <madler@alumni.caltech.edu>
Sun, 11 Dec 2011 06:33:17 +0000 (22:33 -0800)
gzwrite.c had hard-coded parameters to deflateInit2() which could
contradict compile-time options for the use of less memory and fewer
code bits.  This patch suggested by Karsten Saunte fixes that.

gzguts.h
gzwrite.c

index 9daada1fe37ddfc1f877d5f65cc12c62e15c7976..eefdca0f4200b4b1578d84820ce6f7166c74abc1 100644 (file)
--- a/gzguts.h
+++ b/gzguts.h
     ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
 #endif
 
+/* default memLevel */
+#if MAX_MEM_LEVEL >= 8
+#  define DEF_MEM_LEVEL 8
+#else
+#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
+#endif
+
 /* default i/o buffer size -- double this for output when reading */
 #define GZBUFSIZE 8192
 
index 6c991fe4605b6c2d8ecc0ddfb1b293cfc0e0a60b..2dcb3fce6b15d69f6f34d87214db756c390a5d2b 100644 (file)
--- a/gzwrite.c
+++ b/gzwrite.c
@@ -40,7 +40,7 @@ local int gz_init(state)
         strm->zfree = Z_NULL;
         strm->opaque = Z_NULL;
         ret = deflateInit2(strm, state->level, Z_DEFLATED,
-                           15 + 16, 8, state->strategy);
+                           MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy);
         if (ret != Z_OK) {
             free(state->out);
             free(state->in);