summaryrefslogtreecommitdiff
path: root/deflate_fast.c
AgeCommit message (Collapse)Author
2021-12-24Fixed trailing whitespaces and missing new lines.Nathan Moinvaziri
2021-03-20Restore hash_head != 0 checksIlya Leoshkevich
Commit bc5915e2dec7 ("Fixed unsigned integer overflow ASAN error when hash_head > s->strstart.") removed hash_head != 0 checks in fast, medium and slow deflate, because it improved performance [1]. Unfortunately, the attached test started failing after that. Apparently, as the comments suggest, the code implicitly relies on matches with the beginning of the window being skipped. So restore the check. [1] https://github.com/zlib-ng/zlib-ng/pull/772#issuecomment-710760300
2020-10-18Fixed unsigned integer overflow ASAN error when hash_head > s->strstart.Nathan Moinvaziri
zlib-ng/deflate_medium.c:244:47: runtime error: unsigned integer overflow: 58442 - 58452 cannot be represented in type 'unsigned int' Co-authored-by: Mika Lindqvist <postmaster@raasu.org> Co-authored-by: Hans Kristian Rosbach <hk-git@circlestorm.org>
2020-08-31Rename ZLIB_INTERNAL to Z_INTERNAL for consistency.Nathan Moinvaziri
2020-07-03Add likely/unlikely hinting to all deflate algorithms.Hans Kristian Rosbach
2020-06-27Use local variable to store match_len in deflate_fast.Nathan Moinvaziri
2020-06-27Move check for hash_head != 0 directly after quick_insert_string.Nathan Moinvaziri
2020-06-08Move Tracevv statements when emitting literal to zng_tr_tally_lit.Nathan Moinvaziri
2020-05-30Remove IPos typedef which also helps to reduce casting warnings.Nathan Moinvaziri
2020-05-24Simplify generic hash function using knuth's multiplicative hash.Nathan Moinvaziri
2020-05-24Converted compare258 to static and convert longest_match to template.Nathan Moinvaziri
2020-05-06Change two NOT_TWEAK_COMPILER to check for MIN-MATCH!=3 instead.Hans Kristian Rosbach
2020-05-06Remove several NOT_TWEAK_COMPILER checks and their legacy code.Hans Kristian Rosbach
2020-05-01Standardize fill_window implementations and abstract out slide_hash_neon for ↵Nathan Moinvaziri
ARM.
2020-04-30Replaced insert_string with quick_insert_string if length is 1.Nathan Moinvaziri
2020-03-18Clean up usage of bflush make more similar for each deflate strategy.Hans Kristian Rosbach
2020-03-13Clean up zng_tr_tally code.Nathan Moinvaziri
2019-07-18Add zng_ prefix to internal functions to avoid linking conflicts with zlib. ↵Nathan Moinvaziri
(#363)
2019-01-16move match.c to match_p.h and remove match.hSebastian Pop
2018-11-14Fix a bug that can crash deflate on some input when using Z_FIXED.Mark Adler
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-03-22Move private defines from zconf.h and zconf-ng.h to zbuild.hMika Lindqvist
* move definition of z_size_t to zbuild.h
2017-08-17Make sure we don't export internal functionsHans Kristian Rosbach
2017-04-24Add a struct func_table and function functableInit.Hans Kristian Rosbach
The struct contains pointers to select functions to be used by the rest of zlib, and the init function selects what functions will be used depending on what optimizations has been compiled in and what instruction-sets are available at runtime. Tests done on a haswell cpu running minigzip -6 compression of a 40M file shows a 2.5% decrease in branches, and a 25-30% reduction in iTLB-loads. The reduction i iTLB-loads is likely mostly due to the inability to inline functions. This also causes a slight performance regression of around 1%, this might still be worth it to make it much easier to implement new optimized functions for various architectures and instruction sets. The performance penalty will get smaller for functions that get more alternative implementations to choose from, since there is no need to add more branches to every call of the function. Today insert_string has 1 branch to choose insert_string_sse or insert_string_c, but if we also add for example insert_string_sse4 then that would have needed another branch, and it would probably at some point hinder effective inlining too.
2017-01-30Merge insert_string and bulk_insert_str.Mika Lindqvist
** Partial merge of this commit, based on a8c94e9f5a3b9d3c62182bcf84e72304a3c1a6e5 Excludes changes to fill_window_sse.c, changes to fill_window_c() in deflate.c and several unrelated changes in the commit.
2017-01-30Use bulk_insert_str when adding more than one byte.Mika Lindqvist
** Partial merge of this commit, based on f8ad48ab17571c730b743c925f0e13ff83cf487f Excluding changes to fill_window_sse.c, deflate.c and deflate_p.h
2015-06-24Split deflate.cMika Lindqvist
* Separate common inlines and macros to deflate_p.h * Separate deflate_fast related code to deflate_fast.c * Separate deflate_medium related code to deflate_medium.c * Separate deflate_slow related code to deflate_slow.c