Commit Graph

46 Commits

Author SHA1 Message Date
Mark Adler e011d8c164 Add deflateUsed() function to get the used bits in the last byte.
This returns the number of used bits in the last byte of a stream
that has just been compressed with deflate.
2024-07-01 19:34:40 -05:00
Mark Adler 51b7f2abda zlib 1.3.1 2024-01-22 10:32:37 -08:00
Hans Wennborg 60c31985ec Fix the copy of pending_buf in deflateCopy() for the LIT_MEM case. 2024-01-13 22:30:30 -08:00
Mark Adler ac8f12c97d Add LIT_MEM define to use more memory for a small deflate speedup.
A bug fix in zlib 1.2.12 resulted in a slight slowdown (1-2%) of
deflate. This commit provides the option to #define LIT_MEM, which
uses more memory to reverse most of that slowdown. The memory for
the pending buffer and symbol buffers is increased by 25%, which
increases the total memory usage with the default parameters by
about 6%.
2023-09-21 00:14:56 -07:00
Mark Adler e9d5486e66 Remove K&R function definitions from zlib.
C2X has removed K&R definitions from the C function syntax.
Though the standard has not yet been approved, some high-profile
compilers are now issuing warnings when such definitions are
encountered.
2023-04-15 21:17:31 -07:00
Mark Adler 3df842426b Silence some warnings from Visual Studio C. 2022-03-28 10:50:16 -07:00
Mark Adler 21767c654d zlib 1.2.12 2022-03-27 16:05:02 -07:00
Mark Adler 5c44459c3b Fix a bug that can crash deflate on some input when using Z_FIXED.
This bug was reported by Danilo Ramos of Eideticom, Inc. It has
lain in wait 13 years before being found! The bug was introduced
in zlib 1.2.2.2, with the addition of the Z_FIXED option. That
option forces the use of fixed Huffman codes. For rare inputs with
a large number of distant matches, the pending buffer into which
the compressed data is written can overwrite the distance symbol
table which it overlays. That results in corrupted output due to
invalid distances, and can result in out-of-bound accesses,
crashing the application.

The fix here combines the distance buffer and literal/length
buffers into a single symbol buffer. Now three bytes of pending
buffer space are opened up for each literal or length/distance
pair consumed, instead of the previous two bytes. This assures
that the pending buffer cannot overwrite the symbol table, since
the maximum fixed code compressed length/distance is 31 bits, and
since there are four bytes of pending space for every three bytes
of symbol space.
2018-04-19 19:47:11 -07:00
Mark Adler 2fa463bacf zlib 1.2.9 2016-12-31 23:37:10 -08:00
Mark Adler 9674807c82 Fix bugs in creating a very large gzip header. 2016-12-04 07:39:37 -08:00
Mark Adler 7096424f23 Clean up type conversions. 2016-10-11 22:15:50 -07:00
Mark Adler 82e9dc6093 Use const for static tree descriptions in deflate.
This is in order to permit shared memory for these structures.
2015-08-15 18:04:50 -07:00
Mark Adler 51a223def4 Avoid use of DEBUG macro -- change to ZLIB_DEBUG. 2015-07-28 22:44:31 -07:00
Mark Adler ee026accde Correct comment in deflate.h. 2012-06-02 10:16:43 -07:00
Mark Adler 4f5779a8e7 Insert the first two strings in the hash table after a flush.
This allows deflate to generate the same output when continuing after
a Z_SYNC_FLUSH vs. using deflateSetDictionary() after a Z_FULL_FLUSH
or a deflateReset().  It also slightly improves compression when
flushing by providing two more strings to possibly match at the start
of the new block.
2012-01-13 23:54:40 -06:00
Mark Adler 0b828b4aa6 Write out all of the available bits when using Z_BLOCK.
Previously, the bit buffer would hold 1 to 16 bits after "all" of the
output is provided after a Z_BLOCK deflate() call.  Now at most seven
bits remain in the output buffer after Z_BLOCK.  flush_pending() now
flushes the bit buffer before copying out the byte buffer, in order
for it to really flush as much as possible.
2012-01-07 14:08:02 -08:00
Mark Adler 8f5eceefe8 Remove second empty static block for Z_PARTIAL_FLUSH.
Z_PARTIAL_FLUSH would sometimes emit two empty static blocks instead
of one in order to provide enough lookahead for inflate to be able
to decode what was last compressed.  inflate no longer needs that
much lookahead, so this removes the possibility of emitting the
second empty static block.  Z_PARTIAL_FLUSH will now emit only one
empty static block.
2012-01-07 14:03:07 -08:00
Mark Adler 263b1a05b0 Allow deflatePrime() to insert bits in the middle of a stream.
This allows the insertion of multiple empty static blocks for the
purpose of efficiently bringing a stream to a byte boundary.
2012-01-07 14:03:07 -08:00
Mark Adler 10daf0d4d7 zlib 1.2.5.1 2011-09-11 11:04:49 -07:00
Mark Adler 9712272c78 zlib 1.2.5 2011-09-09 23:35:10 -07:00
Mark Adler 7301420248 zlib 1.2.4.5 2011-09-09 23:34:55 -07:00
Mark Adler 67cc20d004 zlib 1.2.4-pre1 2011-09-09 23:32:36 -07:00
Mark Adler f6194ef39a zlib 1.2.3.4 2011-09-09 23:26:40 -07:00
Mark Adler b1c19ca6d8 zlib 1.2.3.1 2011-09-09 23:25:27 -07:00
Mark Adler 9c3a583021 zlib 1.2.2.4 2011-09-09 23:24:52 -07:00
Mark Adler 9811b53dd9 zlib 1.2.2.1 2011-09-09 23:24:24 -07:00
Mark Adler 7a6955760b zlib 1.2.1.2 2011-09-09 23:23:45 -07:00
Mark Adler 4b5a43a219 zlib 1.2.0.5 2011-09-09 23:22:37 -07:00
Mark Adler 086e982175 zlib 1.2.0.4 2011-09-09 23:22:30 -07:00
Mark Adler 8e34b3a802 zlib 1.2.0.2 2011-09-09 23:22:10 -07:00
Mark Adler 13a294f044 zlib 1.2.0.1 2011-09-09 23:21:57 -07:00
Mark Adler a383133c4e zlib 1.1.4 2011-09-09 23:20:42 -07:00
Mark Adler 14763ac7c6 zlib 1.1.3 2011-09-09 23:20:29 -07:00
Mark Adler 02b6cf579f zlib 1.1.1 2011-09-09 23:20:07 -07:00
Mark Adler 965fe72aed zlib 1.1.0 2011-09-09 23:19:55 -07:00
Mark Adler 7850e4e406 zlib 1.0.7 2011-09-09 23:17:33 -07:00
Mark Adler ff11b0a61f zlib 1.0.4 2011-09-09 23:17:02 -07:00
Mark Adler 423eb40306 zlib 1.0.1 2011-09-09 23:14:39 -07:00
Mark Adler 8a2acbffc8 zlib 1.0-pre 2011-09-09 23:13:27 -07:00
Mark Adler 56bcb184fa zlib 0.99 2011-09-09 23:11:37 -07:00
Mark Adler 25e5325501 zlib 0.95 2011-09-09 23:10:21 -07:00
Mark Adler 23c69f1069 zlib 0.94 2011-09-09 23:09:18 -07:00
Mark Adler 6b834a58bd zlib 0.93 2011-09-09 23:08:28 -07:00
Mark Adler bdde4e09d2 zlib 0.92 2011-09-09 23:08:07 -07:00
Mark Adler 64b2e89203 zlib 0.9 2011-09-09 23:06:52 -07:00
Mark Adler bcf78a2097 zlib 0.71 2011-09-09 22:36:31 -07:00