summaryrefslogtreecommitdiff
path: root/deflate.c
diff options
context:
space:
mode:
Diffstat (limited to 'deflate.c')
-rw-r--r--deflate.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/deflate.c b/deflate.c
index ca9dafa..031a1bb 100644
--- a/deflate.c
+++ b/deflate.c
@@ -685,11 +685,11 @@ unsigned long Z_EXPORT PREFIX(deflateBound)(PREFIX3(stream) *strm, unsigned long
wraplen = 0;
break;
case 1: /* zlib wrapper */
- wraplen = 6 + (s->strstart ? 4 : 0);
+ wraplen = ZLIB_WRAPLEN + (s->strstart ? 4 : 0);
break;
#ifdef GZIP
case 2: /* gzip wrapper */
- wraplen = 18;
+ wraplen = GZIP_WRAPLEN;
if (s->gzhead != NULL) { /* user-supplied gzip header */
unsigned char *str;
if (s->gzhead->extra != NULL) {
@@ -713,7 +713,7 @@ unsigned long Z_EXPORT PREFIX(deflateBound)(PREFIX3(stream) *strm, unsigned long
break;
#endif
default: /* for compiler happiness */
- wraplen = 6;
+ wraplen = ZLIB_WRAPLEN;
}
/* if not default parameters, return conservative bound */
@@ -721,8 +721,14 @@ unsigned long Z_EXPORT PREFIX(deflateBound)(PREFIX3(stream) *strm, unsigned long
s->w_bits != 15 || HASH_BITS < 15)
return complen + wraplen;
- /* default settings: return tight bound for that case */
- return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + (sourceLen >> 25) + 13 - 6 + wraplen;
+#ifndef NO_QUICK_STRATEGY
+ return sourceLen /* The source size itself */
+ + DEFLATE_QUICK_OVERHEAD(sourceLen) /* Source encoding overhead, padded to next full byte */
+ + DEFLATE_BLOCK_OVERHEAD /* Deflate block overhead bytes */
+ + wraplen; /* none, zlib or gzip wrapper */
+#else
+ return sourceLen + (sourceLen >> 4) + 7 + wraplen;
+#endif
}
/* =========================================================================