mirror of
				https://github.com/eledio-devices/thirdparty-miniz.git
				synced 2025-10-31 16:14:16 +01:00 
			
		
		
		
	Compare commits
	
		
			31 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 81df2df0f6 | ||
|  | 64d92e19ad | ||
|  | 404c574eba | ||
|  | c1f791f81b | ||
|  | c93e4d804c | ||
|  | 84e8458de0 | ||
|  | 78cdcb0fce | ||
|  | 0d13890f4b | ||
|  | 7ecd1b3677 | ||
|  | a0786b126d | ||
|  | 9b1ddf6861 | ||
|  | 149b34c254 | ||
|  | 6e915ef7fc | ||
|  | 11f795a19c | ||
|  | ec028ffe66 | ||
|  | a6a989cc18 | ||
|  | 3d51050db5 | ||
|  | 3c7177c0cb | ||
|  | 35c2d67bcf | ||
|  | 1c6ca868d7 | ||
|  | 2337db2f7b | ||
|  | 3b3c258b2d | ||
|  | e72ae3f4c2 | ||
|  | 91ce90fa17 | ||
|  | 460e619ae8 | ||
|  | e906a841c7 | ||
|  | a7e7e92a20 | ||
|  | 3b7ee5aea5 | ||
|  | 4c36ab0230 | ||
|  | 4fa873b0f8 | ||
|  | e2c4080f23 | 
| @@ -1,7 +1,7 @@ | ||||
| PROJECT(miniz) | ||||
| cmake_minimum_required(VERSION 2.8) | ||||
| set(CMAKE_BUILD_TYPE Release) | ||||
| set(CMAKE_CONFIGURATION_TYPES Release) | ||||
| set(CMAKE_CONFIGURATION_TYPES Release Debug) | ||||
|  | ||||
| set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) | ||||
|  | ||||
|   | ||||
							
								
								
									
										130
									
								
								ChangeLog.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										130
									
								
								ChangeLog.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,130 @@ | ||||
| ## Changelog | ||||
|  | ||||
| ### 2.0.3 | ||||
|  | ||||
| - Fix GCC/clang compile warnings | ||||
| - Added callback for periodic flushes (for ZIP file streaming) | ||||
| - Use UTF-8 for file names in ZIP files per default | ||||
|  | ||||
| ### 2.0.2 | ||||
|  | ||||
| - Fix source backwards compatibility with 1.x | ||||
| - Fix a ZIP bit not being set correctly | ||||
|  | ||||
| ### 2.0.1 | ||||
|  | ||||
| - Added some tests | ||||
| - Added CI | ||||
| - Make source code ANSI C compatible | ||||
|  | ||||
| ### 2.0.0 beta | ||||
|  | ||||
| - Matthew Sitton merged to vogl ZIP64 changes. Miniz is now licensed as MIT since the vogl code base is MIT licensed | ||||
| - Miniz is now split into several files | ||||
| - Miniz does now not seek backwards when creating ZIP files. That is the ZIP files can be streamed | ||||
| - Miniz automatically switches to the ZIP64 format the created ZIP files goes over ZIP file limits | ||||
| - Similar to [SQLite](https://www.sqlite.org/amalgamation.html) the Miniz source code is amalgamated into one miniz.c/miniz.h pair in a build step (amalgamate.sh). Please use miniz.c/miniz.h in your projects | ||||
|  | ||||
| ### v1.16 BETA Oct 19, 2013 | ||||
|  | ||||
| Still testing, this release is downloadable from [here](http://www.tenacioussoftware.com/miniz_v116_beta_r1.7z). Two key inflator-only robustness and streaming related changes. Also merged in tdefl_compressor_alloc(), tdefl_compressor_free() helpers to make script bindings easier for rustyzip. I would greatly appreciate any help with testing or any feedback. | ||||
|  | ||||
| The inflator in raw (non-zlib) mode is now usable on gzip or similar streams that have a bunch of bytes following the raw deflate data (problem discovered by rustyzip author williamw520). This version should never read beyond the last byte of the raw deflate data independent of how many bytes you pass into the input buffer. | ||||
|  | ||||
| The inflator now has a new failure status TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS (-4). Previously, if the inflator was starved of bytes and could not make progress (because the input buffer was empty and the caller did not set the TINFL_FLAG_HAS_MORE_INPUT flag - say on truncated or corrupted compressed data stream) it would append all 0's to the input and try to soldier on. This is scary behavior if the caller didn't know when to stop accepting output (because it didn't know how much uncompressed data was expected, or didn't enforce a sane maximum). v1.16 will instead return TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS immediately if it needs 1 or more bytes to make progress, the input buf is empty, and the caller has indicated that no more input is available. This is a "soft" failure, so you can call the inflator again with more input and it will try to continue, or you can give up and fail. This could be very useful in network streaming scenarios. | ||||
|  | ||||
| - The inflator coroutine func. is subtle and complex so I'm being cautious about this release. I would greatly appreciate any help with testing or any feedback. | ||||
|          I feel good about these changes, and they've been through several hours of automated testing, but they will probably not fix anything for the majority of prev. users so I'm | ||||
|          going to mark this release as beta for a few weeks and continue testing it at work/home on various things. | ||||
| - The inflator in raw (non-zlib) mode is now usable on gzip or similiar data streams that have a bunch of bytes following the raw deflate data (problem discovered by rustyzip author williamw520). | ||||
|          This version should *never* read beyond the last byte of the raw deflate data independent of how many bytes you pass into the input buffer. This issue was caused by the various Huffman bitbuffer lookahead optimizations, and | ||||
|          would not be an issue if the caller knew and enforced the precise size of the raw compressed data *or* if the compressed data was in zlib format (i.e. always followed by the byte aligned zlib adler32). | ||||
|          So in other words, you can now call the inflator on deflate streams that are followed by arbitrary amounts of data and it's guaranteed that decompression will stop exactly on the last byte. | ||||
| - The inflator now has a new failure status: TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS (-4). Previously, if the inflator was starved of bytes and could not make progress (because the input buffer was empty and the | ||||
|          caller did not set the TINFL_FLAG_HAS_MORE_INPUT flag - say on truncated or corrupted compressed data stream) it would append all 0's to the input and try to soldier on. | ||||
|          This is scary, because in the worst case, I believe it was possible for the prev. inflator to start outputting large amounts of literal data. If the caller didn't know when to stop accepting output | ||||
|          (because it didn't know how much uncompressed data was expected, or didn't enforce a sane maximum) it could continue forever. v1.16 cannot fall into this failure mode, instead it'll return | ||||
|          TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS immediately if it needs 1 or more bytes to make progress, the input buf is empty, and the caller has indicated that no more input is available. This is a "soft" | ||||
|          failure, so you can call the inflator again with more input and it will try to continue, or you can give up and fail. This could be very useful in network streaming scenarios. | ||||
| - Added documentation to all the tinfl return status codes, fixed miniz_tester so it accepts double minus params for Linux, tweaked example1.c, added a simple "follower bytes" test to miniz_tester.cpp. | ||||
| ### v1.15 r4 STABLE - Oct 13, 2013 | ||||
|  | ||||
| Merged over a few very minor bug fixes that I fixed in the zip64 branch. This is downloadable from [here](http://code.google.com/p/miniz/downloads/list) and also in SVN head (as of 10/19/13). | ||||
|  | ||||
|  | ||||
| ### v1.15 - Oct. 13, 2013 | ||||
|  | ||||
| Interim bugfix release while I work on the next major release with zip64 and streaming compression/decompression support. Fixed the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug (thanks kahmyong.moon@hp.com), which could cause the locate files func to not find files when this flag was specified. Also fixed a bug in mz_zip_reader_extract_to_mem_no_alloc() with user provided read buffers (thanks kymoon). I also merged lots of compiler fixes from various github repo branches and Google Code issue reports. I finally added cmake support (only tested under for Linux so far), compiled and tested with clang v3.3 and gcc 4.6 (under Linux), added defl_write_image_to_png_file_in_memory_ex() (supports Y flipping for OpenGL use, real-time compression), added a new PNG example (example6.c - Mandelbrot), and I added 64-bit file I/O support (stat64(), etc.) for glibc. | ||||
|  | ||||
| - Critical fix for the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug (thanks kahmyong.moon@hp.com) which could cause locate files to not find files. This bug | ||||
|         would only have occured in earlier versions if you explicitly used this flag, OR if you used mz_zip_extract_archive_file_to_heap() or mz_zip_add_mem_to_archive_file_in_place() | ||||
|         (which used this flag). If you can't switch to v1.15 but want to fix this bug, just remove the uses of this flag from both helper funcs (and of course don't use the flag). | ||||
| - Bugfix in mz_zip_reader_extract_to_mem_no_alloc() from kymoon when pUser_read_buf is not NULL and compressed size is > uncompressed size | ||||
| - Fixing mz_zip_reader_extract_*() funcs so they don't try to extract compressed data from directory entries, to account for weird zipfiles which contain zero-size compressed data on dir entries. | ||||
|          Hopefully this fix won't cause any issues on weird zip archives, because it assumes the low 16-bits of zip external attributes are DOS attributes (which I believe they always are in practice). | ||||
| - Fixing mz_zip_reader_is_file_a_directory() so it doesn't check the internal attributes, just the filename and external attributes | ||||
| - mz_zip_reader_init_file() - missing MZ_FCLOSE() call if the seek failed | ||||
| - Added cmake support for Linux builds which builds all the examples, tested with clang v3.3 and gcc v4.6. | ||||
| - Clang fix for tdefl_write_image_to_png_file_in_memory() from toffaletti | ||||
| - Merged MZ_FORCEINLINE fix from hdeanclark | ||||
| - Fix <time.h> include before config #ifdef, thanks emil.brink | ||||
| - Added tdefl_write_image_to_png_file_in_memory_ex(): supports Y flipping (super useful for OpenGL apps), and explicit control over the compression level (so you can | ||||
|         set it to 1 for real-time compression). | ||||
| - Merged in some compiler fixes from paulharris's github repro. | ||||
| - Retested this build under Windows (VS 2010, including static analysis), tcc  0.9.26, gcc v4.6 and clang v3.3. | ||||
| - Added example6.c, which dumps an image of the mandelbrot set to a PNG file. | ||||
| - Modified example2 to help test the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY flag more. | ||||
| - In r3: Bugfix to mz_zip_writer_add_file() found during merge: Fix possible src file fclose() leak if alignment bytes+local header file write faiiled | ||||
| - In r4: Minor bugfix to mz_zip_writer_add_from_zip_reader(): Was pushing the wrong central dir header offset, appears harmless in this release, but it became a problem in the zip64 branch | ||||
|  | ||||
| ### v1.14 - May 20, 2012 | ||||
|  | ||||
| (SVN Only) Minor tweaks to get miniz.c compiling with the Tiny C Compiler, added #ifndef MINIZ_NO_TIME guards around utime.h includes. Adding mz_free() function, so the caller can free heap blocks returned by miniz using whatever heap functions it has been configured to use, MSVC specific fixes to use "safe" variants of several functions (localtime_s, fopen_s, freopen_s). | ||||
|  | ||||
| MinGW32/64 GCC 4.6.1 compiler fixes: added MZ_FORCEINLINE, #include <time.h> (thanks fermtect). | ||||
|  | ||||
| Compiler specific fixes, some from fermtect. I upgraded to TDM GCC 4.6.1 and now static __forceinline is giving it fits, so I'm changing all usage of __forceinline to MZ_FORCEINLINE and forcing gcc to use __attribute__((__always_inline__)) (and MSVC to use __forceinline). Also various fixes from fermtect for MinGW32: added #include , 64-bit ftell/fseek fixes. | ||||
|  | ||||
| ### v1.13 - May 19, 2012 | ||||
|  | ||||
| From jason@cornsyrup.org and kelwert@mtu.edu - Most importantly, fixed mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bits. Temporarily/locally slammed in "typedef unsigned long mz_ulong" and re-ran a randomized regression test on ~500k files. Other stuff: | ||||
|  | ||||
| Eliminated a bunch of warnings when compiling with GCC 32-bit/64. Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze (static analysis) option and fixed all warnings (except for the silly "Use of the comma-operator in a tested expression.." analysis warning, which I purposely use to work around a MSVC compiler warning). | ||||
|  | ||||
| Created 32-bit and 64-bit Codeblocks projects/workspace. Built and tested Linux executables. The codeblocks workspace is compatible with Linux+Win32/x64. Added miniz_tester solution/project, which is a useful little app derived from LZHAM's tester app that I use as part of the regression test. Ran miniz.c and tinfl.c through another series of regression testing on ~500,000 files and archives. Modified example5.c so it purposely disables a bunch of high-level functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the MINIZ_NO_STDIO bug report.) | ||||
|  | ||||
| Fix ftell() usage in a few of the examples so they exit with an error on files which are too large (a limitation of the examples, not miniz itself). Fix fail logic handling in mz_zip_add_mem_to_archive_file_in_place() so it always calls mz_zip_writer_finalize_archive() and mz_zip_writer_end(), even if the file add fails. | ||||
|  | ||||
| - From jason@cornsyrup.org and kelwert@mtu.edu - Fix mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bit. | ||||
| - Temporarily/locally slammed in "typedef unsigned long mz_ulong" and re-ran a randomized regression test on ~500k files. | ||||
| - Eliminated a bunch of warnings when compiling with GCC 32-bit/64. | ||||
| - Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze (static analysis) option and fixed all warnings (except for the silly | ||||
| "Use of the comma-operator in a tested expression.." analysis warning, which I purposely use to work around a MSVC compiler warning). | ||||
| - Created 32-bit and 64-bit Codeblocks projects/workspace. Built and tested Linux executables. The codeblocks workspace is compatible with Linux+Win32/x64. | ||||
| - Added miniz_tester solution/project, which is a useful little app derived from LZHAM's tester app that I use as part of the regression test. | ||||
| - Ran miniz.c and tinfl.c through another series of regression testing on ~500,000 files and archives. | ||||
| - Modified example5.c so it purposely disables a bunch of high-level functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the MINIZ_NO_STDIO bug report.) | ||||
| - Fix ftell() usage in examples so they exit with an error on files which are too large (a limitation of the examples, not miniz itself). | ||||
|  | ||||
| ### v1.12 - 4/12/12 | ||||
|  | ||||
| More comments, added low-level example5.c, fixed a couple minor level_and_flags issues in the archive API's. | ||||
| level_and_flags can now be set to MZ_DEFAULT_COMPRESSION. Thanks to Bruce Dawson <bruced@valvesoftware.com> for the feedback/bug report. | ||||
|  | ||||
| ### v1.11 - 5/28/11 | ||||
|  | ||||
| Added statement from unlicense.org | ||||
|  | ||||
| ### v1.10 - 5/27/11 | ||||
|  | ||||
| - Substantial compressor optimizations: | ||||
| - Level 1 is now ~4x faster than before. The L1 compressor's throughput now varies between 70-110MB/sec. on a Core i7 (actual throughput varies depending on the type of data, and x64 vs. x86). | ||||
| - Improved baseline L2-L9 compression perf. Also, greatly improved compression perf. issues on some file types. | ||||
| - Refactored the compression code for better readability and maintainability. | ||||
| - Added level 10 compression level (L10 has slightly better ratio than level 9, but could have a potentially large drop in throughput on some files). | ||||
|  | ||||
| ### v1.09 - 5/15/11 | ||||
|  | ||||
| Initial stable release. | ||||
|  | ||||
|  | ||||
							
								
								
									
										17
									
								
								amalgamate.sh
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										17
									
								
								amalgamate.sh
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @@ -23,10 +23,21 @@ do | ||||
| 	sed -i "s/#include \"$i.h\"//g" $OUTPUT_PREFIX.c | ||||
| done | ||||
|  | ||||
|  | ||||
| echo "int main() { return 0; }" > main.c | ||||
| gcc main.c $OUTPUT_PREFIX.c -o test.out | ||||
| gcc -ansi main.c $OUTPUT_PREFIX.c -o test.out | ||||
| echo "Test compile with GCC..." | ||||
| gcc -pedantic -Wall main.c $OUTPUT_PREFIX.c -o test.out | ||||
| echo "Test compile with GCC ANSI..." | ||||
| gcc -ansi -pedantic -Wall main.c $OUTPUT_PREFIX.c -o test.out | ||||
| if command -v clang | ||||
| then | ||||
| 		echo "Test compile with clang..." | ||||
|         clang -Wall -Wpedantic -fsanitize=unsigned-integer-overflow main.c $OUTPUT_PREFIX.c -o test.out | ||||
| fi | ||||
| for def in MINIZ_NO_STDIO MINIZ_NO_TIME MINIZ_NO_ARCHIVE_APIS MINIZ_NO_ARCHIVE_WRITING_APIS MINIZ_NO_ZLIB_APIS MINIZ_NO_ZLIB_COMPATIBLE_NAMES MINIZ_NO_MALLOC | ||||
| do | ||||
| 	echo "Test compile with GCC and define $def..." | ||||
| 	gcc -ansi -pedantic -Wall main.c $OUTPUT_PREFIX.c -o test.out -D${def} | ||||
| done | ||||
| rm test.out | ||||
| rm main.c | ||||
|  | ||||
|   | ||||
							
								
								
									
										85
									
								
								miniz.c
									
									
									
									
									
								
							
							
						
						
									
										85
									
								
								miniz.c
									
									
									
									
									
								
							| @@ -89,43 +89,43 @@ mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len) | ||||
| { | ||||
|     static const mz_uint32 s_crc_table[256] = | ||||
|         { | ||||
|             0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, | ||||
|             0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, | ||||
|             0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, | ||||
|             0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, | ||||
|             0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, | ||||
|             0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, | ||||
|             0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, | ||||
|             0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, | ||||
|             0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, | ||||
|             0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, | ||||
|             0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, | ||||
|             0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, | ||||
|             0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, | ||||
|             0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, | ||||
|             0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, | ||||
|             0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, | ||||
|             0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, | ||||
|             0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, | ||||
|             0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, | ||||
|             0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, | ||||
|             0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, | ||||
|             0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, | ||||
|             0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, | ||||
|             0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, | ||||
|             0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, | ||||
|             0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, | ||||
|             0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, | ||||
|             0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, | ||||
|             0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, | ||||
|             0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, | ||||
|             0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, | ||||
|             0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, | ||||
|             0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, | ||||
|             0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, | ||||
|             0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, | ||||
|             0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, | ||||
|             0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D | ||||
|           0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, | ||||
|           0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, | ||||
|           0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, | ||||
|           0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, | ||||
|           0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, | ||||
|           0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, | ||||
|           0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, | ||||
|           0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, | ||||
|           0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, | ||||
|           0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, | ||||
|           0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, | ||||
|           0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, | ||||
|           0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, | ||||
|           0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, | ||||
|           0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, | ||||
|           0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, | ||||
|           0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, | ||||
|           0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, | ||||
|           0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, | ||||
|           0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, | ||||
|           0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, | ||||
|           0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, | ||||
|           0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, | ||||
|           0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, | ||||
|           0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, | ||||
|           0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, | ||||
|           0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, | ||||
|           0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, | ||||
|           0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, | ||||
|           0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, | ||||
|           0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, | ||||
|           0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, | ||||
|           0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, | ||||
|           0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, | ||||
|           0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, | ||||
|           0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, | ||||
|           0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D | ||||
|         }; | ||||
|  | ||||
|     mz_uint32 crc32 = (mz_uint32)crc ^ 0xFFFFFFFF; | ||||
| @@ -157,8 +157,6 @@ void mz_free(void *p) | ||||
|     MZ_FREE(p); | ||||
| } | ||||
|  | ||||
| #ifndef MINIZ_NO_ZLIB_APIS | ||||
|  | ||||
| void *miniz_def_alloc_func(void *opaque, size_t items, size_t size) | ||||
| { | ||||
|     (void)opaque, (void)items, (void)size; | ||||
| @@ -180,6 +178,8 @@ const char *mz_version(void) | ||||
|     return MZ_VERSION; | ||||
| } | ||||
|  | ||||
| #ifndef MINIZ_NO_ZLIB_APIS | ||||
|  | ||||
| int mz_deflateInit(mz_streamp pStream, int level) | ||||
| { | ||||
|     return mz_deflateInit2(pStream, level, MZ_DEFLATED, MZ_DEFAULT_WINDOW_BITS, 9, MZ_DEFAULT_STRATEGY); | ||||
| @@ -558,10 +558,9 @@ const char *mz_error(int err) | ||||
|         int m_err; | ||||
|         const char *m_pDesc; | ||||
|     } s_error_descs[] = | ||||
|           { | ||||
|               { MZ_OK, "" }, { MZ_STREAM_END, "stream end" }, { MZ_NEED_DICT, "need dictionary" }, { MZ_ERRNO, "file error" }, { MZ_STREAM_ERROR, "stream error" }, | ||||
|               { MZ_DATA_ERROR, "data error" }, { MZ_MEM_ERROR, "out of memory" }, { MZ_BUF_ERROR, "buf error" }, { MZ_VERSION_ERROR, "version error" }, { MZ_PARAM_ERROR, "parameter error" } | ||||
|           }; | ||||
|         { | ||||
|           { MZ_OK, "" }, { MZ_STREAM_END, "stream end" }, { MZ_NEED_DICT, "need dictionary" }, { MZ_ERRNO, "file error" }, { MZ_STREAM_ERROR, "stream error" }, { MZ_DATA_ERROR, "data error" }, { MZ_MEM_ERROR, "out of memory" }, { MZ_BUF_ERROR, "buf error" }, { MZ_VERSION_ERROR, "version error" }, { MZ_PARAM_ERROR, "parameter error" } | ||||
|         }; | ||||
|     mz_uint i; | ||||
|     for (i = 0; i < sizeof(s_error_descs) / sizeof(s_error_descs[0]); ++i) | ||||
|         if (s_error_descs[i].m_err == err) | ||||
|   | ||||
							
								
								
									
										113
									
								
								miniz.h
									
									
									
									
									
								
							
							
						
						
									
										113
									
								
								miniz.h
									
									
									
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
| /* miniz.c v1.16 beta r1 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing | ||||
| /* miniz.c 2.0.6 beta - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing | ||||
|    See "unlicense" statement at the end of this file. | ||||
|    Rich Geldreich <richgel99@gmail.com>, last updated Oct. 13, 2013 | ||||
|    Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt | ||||
| @@ -6,66 +6,6 @@ | ||||
|    Most API's defined in miniz.c are optional. For example, to disable the archive related functions just define | ||||
|    MINIZ_NO_ARCHIVE_APIS, or to get rid of all stdio usage define MINIZ_NO_STDIO (see the list below for more macros). | ||||
|  | ||||
|    * Change History | ||||
|      10/19/13 v1.16 beta r1 - Two key inflator-only robustness and streaming related changes. Also merged in tdefl_compressor_alloc(), tdefl_compressor_free() helpers to make script bindings easier for rustyzip. | ||||
|        - The inflator coroutine func. is subtle and complex so I'm being cautious about this release. I would greatly appreciate any help with testing or any feedback. | ||||
|          I feel good about these changes, and they've been through several hours of automated testing, but they will probably not fix anything for the majority of prev. users so I'm | ||||
|          going to mark this release as beta for a few weeks and continue testing it at work/home on various things. | ||||
|        - The inflator in raw (non-zlib) mode is now usable on gzip or similiar data streams that have a bunch of bytes following the raw deflate data (problem discovered by rustyzip author williamw520). | ||||
|          This version should *never* read beyond the last byte of the raw deflate data independent of how many bytes you pass into the input buffer. This issue was caused by the various Huffman bitbuffer lookahead optimizations, and | ||||
|          would not be an issue if the caller knew and enforced the precise size of the raw compressed data *or* if the compressed data was in zlib format (i.e. always followed by the byte aligned zlib adler32). | ||||
|          So in other words, you can now call the inflator on deflate streams that are followed by arbitrary amounts of data and it's guaranteed that decompression will stop exactly on the last byte. | ||||
|        - The inflator now has a new failure status: TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS (-4). Previously, if the inflator was starved of bytes and could not make progress (because the input buffer was empty and the | ||||
|          caller did not set the TINFL_FLAG_HAS_MORE_INPUT flag - say on truncated or corrupted compressed data stream) it would append all 0's to the input and try to soldier on. | ||||
|          This is scary, because in the worst case, I believe it was possible for the prev. inflator to start outputting large amounts of literal data. If the caller didn't know when to stop accepting output | ||||
|          (because it didn't know how much uncompressed data was expected, or didn't enforce a sane maximum) it could continue forever. v1.16 cannot fall into this failure mode, instead it'll return | ||||
|          TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS immediately if it needs 1 or more bytes to make progress, the input buf is empty, and the caller has indicated that no more input is available. This is a "soft" | ||||
|          failure, so you can call the inflator again with more input and it will try to continue, or you can give up and fail. This could be very useful in network streaming scenarios. | ||||
|        - Added documentation to all the tinfl return status codes, fixed miniz_tester so it accepts double minus params for Linux, tweaked example1.c, added a simple "follower bytes" test to miniz_tester.cpp. | ||||
|      10/13/13 v1.15 r4 - Interim bugfix release while I work on the next major release with Zip64 support (almost there!): | ||||
|        - Critical fix for the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug (thanks kahmyong.moon@hp.com) which could cause locate files to not find files. This bug | ||||
|         would only have occured in earlier versions if you explicitly used this flag, OR if you used mz_zip_extract_archive_file_to_heap() or mz_zip_add_mem_to_archive_file_in_place() | ||||
|         (which used this flag). If you can't switch to v1.15 but want to fix this bug, just remove the uses of this flag from both helper funcs (and of course don't use the flag). | ||||
|        - Bugfix in mz_zip_reader_extract_to_mem_no_alloc() from kymoon when pUser_read_buf is not NULL and compressed size is > uncompressed size | ||||
|        - Fixing mz_zip_reader_extract_*() funcs so they don't try to extract compressed data from directory entries, to account for weird zipfiles which contain zero-size compressed data on dir entries. | ||||
|          Hopefully this fix won't cause any issues on weird zip archives, because it assumes the low 16-bits of zip external attributes are DOS attributes (which I believe they always are in practice). | ||||
|        - Fixing mz_zip_reader_is_file_a_directory() so it doesn't check the internal attributes, just the filename and external attributes | ||||
|        - mz_zip_reader_init_file() - missing MZ_FCLOSE() call if the seek failed | ||||
|        - Added cmake support for Linux builds which builds all the examples, tested with clang v3.3 and gcc v4.6. | ||||
|        - Clang fix for tdefl_write_image_to_png_file_in_memory() from toffaletti | ||||
|        - Merged MZ_FORCEINLINE fix from hdeanclark | ||||
|        - Fix <time.h> include before config #ifdef, thanks emil.brink | ||||
|        - Added tdefl_write_image_to_png_file_in_memory_ex(): supports Y flipping (super useful for OpenGL apps), and explicit control over the compression level (so you can | ||||
|         set it to 1 for real-time compression). | ||||
|        - Merged in some compiler fixes from paulharris's github repro. | ||||
|        - Retested this build under Windows (VS 2010, including static analysis), tcc  0.9.26, gcc v4.6 and clang v3.3. | ||||
|        - Added example6.c, which dumps an image of the mandelbrot set to a PNG file. | ||||
|        - Modified example2 to help test the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY flag more. | ||||
|        - In r3: Bugfix to mz_zip_writer_add_file() found during merge: Fix possible src file fclose() leak if alignment bytes+local header file write faiiled | ||||
| 		 - In r4: Minor bugfix to mz_zip_writer_add_from_zip_reader(): Was pushing the wrong central dir header offset, appears harmless in this release, but it became a problem in the zip64 branch | ||||
|      5/20/12 v1.14 - MinGW32/64 GCC 4.6.1 compiler fixes: added MZ_FORCEINLINE, #include <time.h> (thanks fermtect). | ||||
|      5/19/12 v1.13 - From jason@cornsyrup.org and kelwert@mtu.edu - Fix mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bit. | ||||
|        - Temporarily/locally slammed in "typedef unsigned long mz_ulong" and re-ran a randomized regression test on ~500k files. | ||||
|        - Eliminated a bunch of warnings when compiling with GCC 32-bit/64. | ||||
|        - Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze (static analysis) option and fixed all warnings (except for the silly | ||||
|         "Use of the comma-operator in a tested expression.." analysis warning, which I purposely use to work around a MSVC compiler warning). | ||||
|        - Created 32-bit and 64-bit Codeblocks projects/workspace. Built and tested Linux executables. The codeblocks workspace is compatible with Linux+Win32/x64. | ||||
|        - Added miniz_tester solution/project, which is a useful little app derived from LZHAM's tester app that I use as part of the regression test. | ||||
|        - Ran miniz.c and tinfl.c through another series of regression testing on ~500,000 files and archives. | ||||
|        - Modified example5.c so it purposely disables a bunch of high-level functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the MINIZ_NO_STDIO bug report.) | ||||
|        - Fix ftell() usage in examples so they exit with an error on files which are too large (a limitation of the examples, not miniz itself). | ||||
|      4/12/12 v1.12 - More comments, added low-level example5.c, fixed a couple minor level_and_flags issues in the archive API's. | ||||
|       level_and_flags can now be set to MZ_DEFAULT_COMPRESSION. Thanks to Bruce Dawson <bruced@valvesoftware.com> for the feedback/bug report. | ||||
|      5/28/11 v1.11 - Added statement from unlicense.org | ||||
|      5/27/11 v1.10 - Substantial compressor optimizations: | ||||
|       - Level 1 is now ~4x faster than before. The L1 compressor's throughput now varies between 70-110MB/sec. on a | ||||
|       - Core i7 (actual throughput varies depending on the type of data, and x64 vs. x86). | ||||
|       - Improved baseline L2-L9 compression perf. Also, greatly improved compression perf. issues on some file types. | ||||
|       - Refactored the compression code for better readability and maintainability. | ||||
|       - Added level 10 compression level (L10 has slightly better ratio than level 9, but could have a potentially large | ||||
|        drop in throughput on some files). | ||||
|      5/15/11 v1.09 - Initial stable release. | ||||
|  | ||||
|    * Low-level Deflate/Inflate implementation notes: | ||||
|  | ||||
|      Compression: Use the "tdefl" API's. The compressor supports raw, static, and dynamic blocks, lazy or | ||||
| @@ -190,7 +130,7 @@ | ||||
| /* Define MINIZ_NO_ARCHIVE_APIS to disable all ZIP archive API's. */ | ||||
| /*#define MINIZ_NO_ARCHIVE_APIS */ | ||||
|  | ||||
| /* Define MINIZ_NO_ARCHIVE_APIS to disable all writing related ZIP archive API's. */ | ||||
| /* Define MINIZ_NO_ARCHIVE_WRITING_APIS to disable all writing related ZIP archive API's. */ | ||||
| /*#define MINIZ_NO_ARCHIVE_WRITING_APIS */ | ||||
|  | ||||
| /* Define MINIZ_NO_ZLIB_APIS to remove all ZLIB-style compression/decompression API's. */ | ||||
| @@ -210,6 +150,8 @@ | ||||
| #define MINIZ_NO_TIME | ||||
| #endif | ||||
|  | ||||
| #include <stddef.h> | ||||
|  | ||||
| #if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS) | ||||
| #include <time.h> | ||||
| #endif | ||||
| @@ -217,21 +159,29 @@ | ||||
| #if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__) | ||||
| /* MINIZ_X86_OR_X64_CPU is only used to help set the below macros. */ | ||||
| #define MINIZ_X86_OR_X64_CPU 1 | ||||
| #else | ||||
| #define MINIZ_X86_OR_X64_CPU 0 | ||||
| #endif | ||||
|  | ||||
| #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU | ||||
| /* Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian. */ | ||||
| #define MINIZ_LITTLE_ENDIAN 1 | ||||
| #else | ||||
| #define MINIZ_LITTLE_ENDIAN 0 | ||||
| #endif | ||||
|  | ||||
| #if MINIZ_X86_OR_X64_CPU | ||||
| /* Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient integer loads and stores from unaligned addresses. */ | ||||
| #define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 | ||||
| #else | ||||
| #define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 0 | ||||
| #endif | ||||
|  | ||||
| #if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__) || defined(__ia64__) || defined(__x86_64__) | ||||
| /* Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are reasonably fast (and don't involve compiler generated calls to helper functions). */ | ||||
| #define MINIZ_HAS_64BIT_REGISTERS 1 | ||||
| #else | ||||
| #define MINIZ_HAS_64BIT_REGISTERS 0 | ||||
| #endif | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| @@ -267,22 +217,32 @@ enum | ||||
| /* Method */ | ||||
| #define MZ_DEFLATED 8 | ||||
|  | ||||
| #ifndef MINIZ_NO_ZLIB_APIS | ||||
|  | ||||
| /* Heap allocation callbacks. | ||||
|    Note that mz_alloc_func parameter types purpsosely differ from zlib's: items/size is size_t, not unsigned long. */ | ||||
| Note that mz_alloc_func parameter types purpsosely differ from zlib's: items/size is size_t, not unsigned long. */ | ||||
| typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size); | ||||
| typedef void (*mz_free_func)(void *opaque, void *address); | ||||
| typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, size_t size); | ||||
|  | ||||
| /* TODO: I can't encode "1.16" here, argh */ | ||||
| #define MZ_VERSION "9.1.15" | ||||
| #define MZ_VERNUM 0x91F0 | ||||
| #define MZ_VER_MAJOR 9 | ||||
| #define MZ_VER_MINOR 1 | ||||
| #define MZ_VER_REVISION 15 | ||||
| /* Compression levels: 0-9 are the standard zlib-style levels, 10 is best possible compression (not zlib compatible, and may be very slow), MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL. */ | ||||
| enum | ||||
| { | ||||
|     MZ_NO_COMPRESSION = 0, | ||||
|     MZ_BEST_SPEED = 1, | ||||
|     MZ_BEST_COMPRESSION = 9, | ||||
|     MZ_UBER_COMPRESSION = 10, | ||||
|     MZ_DEFAULT_LEVEL = 6, | ||||
|     MZ_DEFAULT_COMPRESSION = -1 | ||||
| }; | ||||
|  | ||||
| #define MZ_VERSION "10.0.1" | ||||
| #define MZ_VERNUM 0xA010 | ||||
| #define MZ_VER_MAJOR 10 | ||||
| #define MZ_VER_MINOR 0 | ||||
| #define MZ_VER_REVISION 1 | ||||
| #define MZ_VER_SUBREVISION 0 | ||||
|  | ||||
| #ifndef MINIZ_NO_ZLIB_APIS | ||||
|  | ||||
| /* Flush values. For typical usage you only need MZ_NO_FLUSH and MZ_FINISH. The other values are for advanced use (refer to the zlib docs). */ | ||||
| enum | ||||
| { | ||||
| @@ -309,17 +269,6 @@ enum | ||||
|     MZ_PARAM_ERROR = -10000 | ||||
| }; | ||||
|  | ||||
| /* Compression levels: 0-9 are the standard zlib-style levels, 10 is best possible compression (not zlib compatible, and may be very slow), MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL. */ | ||||
| enum | ||||
| { | ||||
|     MZ_NO_COMPRESSION = 0, | ||||
|     MZ_BEST_SPEED = 1, | ||||
|     MZ_BEST_COMPRESSION = 9, | ||||
|     MZ_UBER_COMPRESSION = 10, | ||||
|     MZ_DEFAULT_LEVEL = 6, | ||||
|     MZ_DEFAULT_COMPRESSION = -1 | ||||
| }; | ||||
|  | ||||
| /* Window bits */ | ||||
| #define MZ_DEFAULT_WINDOW_BITS 15 | ||||
|  | ||||
|   | ||||
| @@ -1,8 +1,8 @@ | ||||
| #pragma once | ||||
| #include <assert.h> | ||||
| #include <stdint.h> | ||||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
| #include <stdint.h> | ||||
|  | ||||
| /* ------------------- Types and macros */ | ||||
| typedef unsigned char mz_uint8; | ||||
|   | ||||
							
								
								
									
										134
									
								
								miniz_tdef.c
									
									
									
									
									
								
							
							
						
						
									
										134
									
								
								miniz_tdef.c
									
									
									
									
									
								
							| @@ -36,64 +36,64 @@ extern "C" { | ||||
| /* Purposely making these tables static for faster init and thread safety. */ | ||||
| static const mz_uint16 s_tdefl_len_sym[256] = | ||||
|     { | ||||
|         257, 258, 259, 260, 261, 262, 263, 264, 265, 265, 266, 266, 267, 267, 268, 268, 269, 269, 269, 269, 270, 270, 270, 270, 271, 271, 271, 271, 272, 272, 272, 272, | ||||
|         273, 273, 273, 273, 273, 273, 273, 273, 274, 274, 274, 274, 274, 274, 274, 274, 275, 275, 275, 275, 275, 275, 275, 275, 276, 276, 276, 276, 276, 276, 276, 276, | ||||
|         277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, | ||||
|         279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, | ||||
|         281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, | ||||
|         282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, | ||||
|         283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, | ||||
|         284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 285 | ||||
|       257, 258, 259, 260, 261, 262, 263, 264, 265, 265, 266, 266, 267, 267, 268, 268, 269, 269, 269, 269, 270, 270, 270, 270, 271, 271, 271, 271, 272, 272, 272, 272, | ||||
|       273, 273, 273, 273, 273, 273, 273, 273, 274, 274, 274, 274, 274, 274, 274, 274, 275, 275, 275, 275, 275, 275, 275, 275, 276, 276, 276, 276, 276, 276, 276, 276, | ||||
|       277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, | ||||
|       279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, | ||||
|       281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, | ||||
|       282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, | ||||
|       283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, | ||||
|       284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 285 | ||||
|     }; | ||||
|  | ||||
| static const mz_uint8 s_tdefl_len_extra[256] = | ||||
|     { | ||||
|         0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, | ||||
|         4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, | ||||
|         5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, | ||||
|         5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0 | ||||
|       0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, | ||||
|       4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, | ||||
|       5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, | ||||
|       5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0 | ||||
|     }; | ||||
|  | ||||
| static const mz_uint8 s_tdefl_small_dist_sym[512] = | ||||
|     { | ||||
|         0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, | ||||
|         11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, | ||||
|         13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, | ||||
|         14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, | ||||
|         14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, | ||||
|         15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, | ||||
|         16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, | ||||
|         16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, | ||||
|         16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, | ||||
|         17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, | ||||
|         17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, | ||||
|         17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17 | ||||
|       0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, | ||||
|       11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, | ||||
|       13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, | ||||
|       14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, | ||||
|       14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, | ||||
|       15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, | ||||
|       16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, | ||||
|       16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, | ||||
|       16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, | ||||
|       17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, | ||||
|       17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, | ||||
|       17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17 | ||||
|     }; | ||||
|  | ||||
| static const mz_uint8 s_tdefl_small_dist_extra[512] = | ||||
|     { | ||||
|         0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, | ||||
|         5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, | ||||
|         6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, | ||||
|         6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | ||||
|         7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | ||||
|         7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | ||||
|         7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | ||||
|         7, 7, 7, 7, 7, 7, 7, 7 | ||||
|       0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, | ||||
|       5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, | ||||
|       6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, | ||||
|       6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | ||||
|       7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | ||||
|       7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | ||||
|       7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | ||||
|       7, 7, 7, 7, 7, 7, 7, 7 | ||||
|     }; | ||||
|  | ||||
| static const mz_uint8 s_tdefl_large_dist_sym[128] = | ||||
|     { | ||||
|         0, 0, 18, 19, 20, 20, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, | ||||
|         26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, | ||||
|         28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 | ||||
|       0, 0, 18, 19, 20, 20, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, | ||||
|       26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, | ||||
|       28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 | ||||
|     }; | ||||
|  | ||||
| static const mz_uint8 s_tdefl_large_dist_extra[128] = | ||||
|     { | ||||
|         0, 0, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, | ||||
|         12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, | ||||
|         13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13 | ||||
|       0, 0, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, | ||||
|       12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, | ||||
|       13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13 | ||||
|     }; | ||||
|  | ||||
| /* Radix sorts tdefl_sym_freq[] array by 16-bit key m_key. Returns ptr to sorted values. */ | ||||
| @@ -449,7 +449,7 @@ static void tdefl_start_static_block(tdefl_compressor *d) | ||||
|  | ||||
| static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF }; | ||||
|  | ||||
| #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES &&MINIZ_LITTLE_ENDIAN &&MINIZ_HAS_64BIT_REGISTERS | ||||
| #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS | ||||
| static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) | ||||
| { | ||||
|     mz_uint flags; | ||||
| @@ -737,13 +737,29 @@ static int tdefl_flush_block(tdefl_compressor *d, int flush) | ||||
| } | ||||
|  | ||||
| #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES | ||||
| #ifdef MINIZ_UNALIGNED_USE_MEMCPY | ||||
| static inline mz_uint16 TDEFL_READ_UNALIGNED_WORD(const mz_uint8* p) | ||||
| { | ||||
| 	mz_uint16 ret; | ||||
| 	memcpy(&ret, p, sizeof(mz_uint16)); | ||||
| 	return ret; | ||||
| } | ||||
| static inline mz_uint16 TDEFL_READ_UNALIGNED_WORD2(const mz_uint16* p) | ||||
| { | ||||
| 	mz_uint16 ret; | ||||
| 	memcpy(&ret, p, sizeof(mz_uint16)); | ||||
| 	return ret; | ||||
| } | ||||
| #else | ||||
| #define TDEFL_READ_UNALIGNED_WORD(p) *(const mz_uint16 *)(p) | ||||
| #define TDEFL_READ_UNALIGNED_WORD2(p) *(const mz_uint16 *)(p) | ||||
| #endif | ||||
| static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) | ||||
| { | ||||
|     mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len; | ||||
|     mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; | ||||
|     const mz_uint16 *s = (const mz_uint16 *)(d->m_dict + pos), *p, *q; | ||||
|     mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]), s01 = TDEFL_READ_UNALIGNED_WORD(s); | ||||
|     mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]), s01 = TDEFL_READ_UNALIGNED_WORD2(s); | ||||
|     MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); | ||||
|     if (max_match_len <= match_len) | ||||
|         return; | ||||
| @@ -767,14 +783,14 @@ static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahe | ||||
|         if (!dist) | ||||
|             break; | ||||
|         q = (const mz_uint16 *)(d->m_dict + probe_pos); | ||||
|         if (TDEFL_READ_UNALIGNED_WORD(q) != s01) | ||||
|         if (TDEFL_READ_UNALIGNED_WORD2(q) != s01) | ||||
|             continue; | ||||
|         p = s; | ||||
|         probe_len = 32; | ||||
|         do | ||||
|         { | ||||
|         } while ((TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && | ||||
|                  (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0)); | ||||
|         } while ((TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && | ||||
|                  (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (--probe_len > 0)); | ||||
|         if (!probe_len) | ||||
|         { | ||||
|             *pMatch_dist = dist; | ||||
| @@ -836,7 +852,7 @@ static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahe | ||||
| } | ||||
| #endif /* #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES */ | ||||
|  | ||||
| #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES &&MINIZ_LITTLE_ENDIAN | ||||
| #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN | ||||
| static mz_bool tdefl_compress_fast(tdefl_compressor *d) | ||||
| { | ||||
|     /* Faster, minimally featured LZRW1-style match+parse loop with better register utilization. Intended for applications where raw throughput is valued more highly than ratio. */ | ||||
| @@ -883,8 +899,8 @@ static mz_bool tdefl_compress_fast(tdefl_compressor *d) | ||||
|                 mz_uint32 probe_len = 32; | ||||
|                 do | ||||
|                 { | ||||
|                 } while ((TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && | ||||
|                          (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0)); | ||||
|                 } while ((TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && | ||||
|                          (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (--probe_len > 0)); | ||||
|                 cur_match_len = ((mz_uint)(p - (const mz_uint16 *)pCur_dict) * 2) + (mz_uint)(*(const mz_uint8 *)p == *(const mz_uint8 *)q); | ||||
|                 if (!probe_len) | ||||
|                     cur_match_len = cur_match_dist ? TDEFL_MAX_MATCH_LEN : 0; | ||||
| @@ -1250,7 +1266,7 @@ tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pI | ||||
|     if ((d->m_output_flush_remaining) || (d->m_finished)) | ||||
|         return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); | ||||
|  | ||||
| #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES &&MINIZ_LITTLE_ENDIAN | ||||
| #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN | ||||
|     if (((d->m_flags & TDEFL_MAX_PROBES_MASK) == 1) && | ||||
|         ((d->m_flags & TDEFL_GREEDY_PARSING_FLAG) != 0) && | ||||
|         ((d->m_flags & (TDEFL_FILTER_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS | TDEFL_RLE_MATCHES)) == 0)) | ||||
| @@ -1408,7 +1424,6 @@ size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void | ||||
|     return out_buf.m_size; | ||||
| } | ||||
|  | ||||
| #ifndef MINIZ_NO_ZLIB_APIS | ||||
| static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 }; | ||||
|  | ||||
| /* level may actually range from [0,10] (10 is a "hidden" max level, where we want a bit more compression and it's fine if throughput to fall off a cliff on some files). */ | ||||
| @@ -1431,7 +1446,6 @@ mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int | ||||
|  | ||||
|     return comp_flags; | ||||
| } | ||||
| #endif /*MINIZ_NO_ZLIB_APIS */ | ||||
|  | ||||
| #ifdef _MSC_VER | ||||
| #pragma warning(push) | ||||
| @@ -1480,9 +1494,24 @@ void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int | ||||
|     *pLen_out = out_buf.m_size - 41; | ||||
|     { | ||||
|         static const mz_uint8 chans[] = { 0x00, 0x00, 0x04, 0x02, 0x06 }; | ||||
|         mz_uint8 pnghdr[41] = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, | ||||
|                                 0, 0, (mz_uint8)(w >> 8), (mz_uint8)w, 0, 0, (mz_uint8)(h >> 8), (mz_uint8)h, 8, chans[num_chans], 0, 0, 0, 0, 0, 0, 0, | ||||
|                                 (mz_uint8)(*pLen_out >> 24), (mz_uint8)(*pLen_out >> 16), (mz_uint8)(*pLen_out >> 8), (mz_uint8)*pLen_out, 0x49, 0x44, 0x41, 0x54 }; | ||||
|         mz_uint8 pnghdr[41] = { 0x89, 0x50, 0x4e, 0x47, 0x0d, | ||||
|                                 0x0a, 0x1a, 0x0a, 0x00, 0x00, | ||||
|                                 0x00, 0x0d, 0x49, 0x48, 0x44, | ||||
|                                 0x52, 0x00, 0x00, 0x00, 0x00, | ||||
|                                 0x00, 0x00, 0x00, 0x00, 0x08, | ||||
|                                 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
|                                 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
|                                 0x00, 0x00, 0x49, 0x44, 0x41, | ||||
|                                 0x54 }; | ||||
|         pnghdr[18] = (mz_uint8)(w >> 8); | ||||
|         pnghdr[19] = (mz_uint8)w; | ||||
|         pnghdr[22] = (mz_uint8)(h >> 8); | ||||
|         pnghdr[23] = (mz_uint8)h; | ||||
|         pnghdr[25] = chans[num_chans]; | ||||
|         pnghdr[33] = (mz_uint8)(*pLen_out >> 24); | ||||
|         pnghdr[34] = (mz_uint8)(*pLen_out >> 16); | ||||
|         pnghdr[35] = (mz_uint8)(*pLen_out >> 8); | ||||
|         pnghdr[36] = (mz_uint8)*pLen_out; | ||||
|         c = (mz_uint32)mz_crc32(MZ_CRC32_INIT, pnghdr + 12, 17); | ||||
|         for (i = 0; i < 4; ++i, c <<= 8) | ||||
|             ((mz_uint8 *)(pnghdr + 29))[i] = (mz_uint8)(c >> 24); | ||||
| @@ -1530,4 +1559,3 @@ void tdefl_compressor_free(tdefl_compressor *pComp) | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
|  | ||||
|   | ||||
							
								
								
									
										11
									
								
								miniz_tdef.h
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								miniz_tdef.h
									
									
									
									
									
								
							| @@ -111,17 +111,15 @@ enum | ||||
| #endif | ||||
|  | ||||
| /* The low-level tdefl functions below may be used directly if the above helper functions aren't flexible enough. The low-level functions don't make any heap allocations, unlike the above helper functions. */ | ||||
| typedef enum | ||||
| { | ||||
| typedef enum { | ||||
|     TDEFL_STATUS_BAD_PARAM = -2, | ||||
|     TDEFL_STATUS_PUT_BUF_FAILED = -1, | ||||
|     TDEFL_STATUS_OKAY = 0, | ||||
|     TDEFL_STATUS_DONE = 1, | ||||
|     TDEFL_STATUS_DONE = 1 | ||||
| } tdefl_status; | ||||
|  | ||||
| /* Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums */ | ||||
| typedef enum | ||||
| { | ||||
| typedef enum { | ||||
|     TDEFL_NO_FLUSH = 0, | ||||
|     TDEFL_SYNC_FLUSH = 2, | ||||
|     TDEFL_FULL_FLUSH = 3, | ||||
| @@ -173,14 +171,11 @@ tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, siz | ||||
| tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d); | ||||
| mz_uint32 tdefl_get_adler32(tdefl_compressor *d); | ||||
|  | ||||
| /* Can't use tdefl_create_comp_flags_from_zip_params if MINIZ_NO_ZLIB_APIS isn't defined, because it uses some of its macros. */ | ||||
| #ifndef MINIZ_NO_ZLIB_APIS | ||||
| /* Create tdefl_compress() flags given zlib-style compression parameters. */ | ||||
| /* level may range from [0,10] (where 10 is absolute max compression, but may be much slower on some files) */ | ||||
| /* window_bits may be -15 (raw deflate) or 15 (zlib) */ | ||||
| /* strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, MZ_RLE, or MZ_FIXED */ | ||||
| mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy); | ||||
| #endif /* #ifndef MINIZ_NO_ZLIB_APIS */ | ||||
|  | ||||
| /* Allocate the tdefl_compressor structure in C so that */ | ||||
| /* non-C language bindings to tdefl_ API don't need to worry about */ | ||||
|   | ||||
| @@ -23,14 +23,13 @@ | ||||
|  * THE SOFTWARE. | ||||
|  * | ||||
|  **************************************************************************/ | ||||
|   | ||||
|  | ||||
| #include "miniz_tinfl.h" | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* ------------------- Low-level Decompression (completely independent from all compression API's) */ | ||||
|  | ||||
| #define TINFL_MEMCPY(d, s, l) memcpy(d, s, l) | ||||
| @@ -60,15 +59,15 @@ extern "C" { | ||||
|     MZ_MACRO_END | ||||
| #define TINFL_CR_FINISH } | ||||
|  | ||||
| #define TINFL_GET_BYTE(state_index, c)                                                                                                                          \ | ||||
|     do                                                                                                                                                          \ | ||||
|     {                                                                                                                                                           \ | ||||
|         while (pIn_buf_cur >= pIn_buf_end)                                                                                                                      \ | ||||
|         {                                                                                                                                                       \ | ||||
|             TINFL_CR_RETURN(state_index, (decomp_flags &TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS); \ | ||||
|         }                                                                                                                                                       \ | ||||
|         c = *pIn_buf_cur++;                                                                                                                                     \ | ||||
|     }                                                                                                                                                           \ | ||||
| #define TINFL_GET_BYTE(state_index, c)                                                                                                                           \ | ||||
|     do                                                                                                                                                           \ | ||||
|     {                                                                                                                                                            \ | ||||
|         while (pIn_buf_cur >= pIn_buf_end)                                                                                                                       \ | ||||
|         {                                                                                                                                                        \ | ||||
|             TINFL_CR_RETURN(state_index, (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS); \ | ||||
|         }                                                                                                                                                        \ | ||||
|         c = *pIn_buf_cur++;                                                                                                                                      \ | ||||
|     }                                                                                                                                                            \ | ||||
|     MZ_MACRO_END | ||||
|  | ||||
| #define TINFL_NEED_BITS(state_index, n)                \ | ||||
| @@ -186,7 +185,7 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex | ||||
|     tinfl_bit_buf_t bit_buf; | ||||
|     const mz_uint8 *pIn_buf_cur = pIn_buf_next, *const pIn_buf_end = pIn_buf_next + *pIn_buf_size; | ||||
|     mz_uint8 *pOut_buf_cur = pOut_buf_next, *const pOut_buf_end = pOut_buf_next + *pOut_buf_size; | ||||
|     size_t out_buf_size_mask = (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF) ? (size_t) - 1 : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1, dist_from_out_buf_start; | ||||
|     size_t out_buf_size_mask = (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF) ? (size_t)-1 : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1, dist_from_out_buf_start; | ||||
|  | ||||
|     /* Ensure the output buffer's size is a power of 2, unless the output buffer is large enough to hold the entire output file (in which case it doesn't matter). */ | ||||
|     if (((out_buf_size_mask + 1) & out_buf_size_mask) || (pOut_buf_next < pOut_buf_start)) | ||||
| @@ -568,7 +567,7 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex | ||||
|         --pIn_buf_cur; | ||||
|         num_bits -= 8; | ||||
|     } | ||||
|     bit_buf &= (tinfl_bit_buf_t)((1ULL << num_bits) - 1ULL); | ||||
|     bit_buf &= (tinfl_bit_buf_t)((((mz_uint64)1) << num_bits) - (mz_uint64)1); | ||||
|     MZ_ASSERT(!num_bits); /* if this assert fires then we've read beyond the end of non-deflate/zlib streams with following data (such as gzip streams). */ | ||||
|  | ||||
|     if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) | ||||
| @@ -600,7 +599,7 @@ common_exit: | ||||
|         } | ||||
|     } | ||||
|     r->m_num_bits = num_bits; | ||||
|     r->m_bit_buf = bit_buf & (tinfl_bit_buf_t)((1ULL << num_bits) - 1ULL); | ||||
|     r->m_bit_buf = bit_buf & (tinfl_bit_buf_t)((((mz_uint64)1) << num_bits) - (mz_uint64)1); | ||||
|     r->m_dist = dist; | ||||
|     r->m_counter = counter; | ||||
|     r->m_num_extra = num_extra; | ||||
| @@ -732,4 +731,3 @@ void tinfl_decompressor_free(tinfl_decompressor *pDecomp) | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -52,8 +52,7 @@ void tinfl_decompressor_free(tinfl_decompressor *pDecomp); | ||||
| #define TINFL_LZ_DICT_SIZE 32768 | ||||
|  | ||||
| /* Return status. */ | ||||
| typedef enum | ||||
| { | ||||
| typedef enum { | ||||
|     /* This flags indicates the inflator needs 1 or more input bytes to make forward progress, but the caller is indicating that no more are available. The compressed data */ | ||||
|     /* is probably corrupted. If you call the inflator again with more bytes it'll try to continue processing the input but this is a BAD sign (either the data is corrupted or you called it incorrectly). */ | ||||
|     /* If you call it again with no input you'll just get TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS again. */ | ||||
| @@ -84,7 +83,6 @@ typedef enum | ||||
|     /* (either exact or worst case) and will stop calling the inflator and fail after receiving too much. In pure streaming scenarios where you have no idea how many bytes to expect this may not be possible */ | ||||
|     /* so I may need to add some code to address this. */ | ||||
|     TINFL_STATUS_HAS_MORE_OUTPUT = 2 | ||||
|  | ||||
| } tinfl_status; | ||||
|  | ||||
| /* Initializes the decompressor to its initial state. */ | ||||
| @@ -119,6 +117,8 @@ typedef struct | ||||
|  | ||||
| #if MINIZ_HAS_64BIT_REGISTERS | ||||
| #define TINFL_USE_64BIT_BITBUF 1 | ||||
| #else | ||||
| #define TINFL_USE_64BIT_BITBUF 0 | ||||
| #endif | ||||
|  | ||||
| #if TINFL_USE_64BIT_BITBUF | ||||
|   | ||||
							
								
								
									
										864
									
								
								miniz_zip.c
									
									
									
									
									
								
							
							
						
						
									
										864
									
								
								miniz_zip.c
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										80
									
								
								miniz_zip.h
									
									
									
									
									
								
							
							
						
						
									
										80
									
								
								miniz_zip.h
									
									
									
									
									
								
							| @@ -4,6 +4,8 @@ | ||||
|  | ||||
| /* ------------------- ZIP archive reading/writing */ | ||||
|  | ||||
| #ifndef MINIZ_NO_ARCHIVE_APIS | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| #endif | ||||
| @@ -74,33 +76,31 @@ typedef struct | ||||
|  | ||||
| typedef size_t (*mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n); | ||||
| typedef size_t (*mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n); | ||||
| typedef mz_bool (*mz_file_needs_keepalive)(void *pOpaque); | ||||
|  | ||||
| struct mz_zip_internal_state_tag; | ||||
| typedef struct mz_zip_internal_state_tag mz_zip_internal_state; | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| typedef enum { | ||||
|     MZ_ZIP_MODE_INVALID = 0, | ||||
|     MZ_ZIP_MODE_READING = 1, | ||||
|     MZ_ZIP_MODE_WRITING = 2, | ||||
|     MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED = 3 | ||||
| } mz_zip_mode; | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| typedef enum { | ||||
|     MZ_ZIP_FLAG_CASE_SENSITIVE = 0x0100, | ||||
|     MZ_ZIP_FLAG_IGNORE_PATH = 0x0200, | ||||
|     MZ_ZIP_FLAG_COMPRESSED_DATA = 0x0400, | ||||
|     MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY = 0x0800, | ||||
|     MZ_ZIP_FLAG_VALIDATE_LOCATE_FILE_FLAG = 0x1000, /* if enabled, mz_zip_reader_locate_file() will be called on each file as its validated to ensure the func finds the file in the central dir (intended for testing) */ | ||||
|     MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY = 0x2000,     /* validate the local headers, but don't decompress the entire file and check the crc32 */ | ||||
|     MZ_ZIP_FLAG_WRITE_ZIP64 = 0x4000,               /* use the zip64 file format, instead of the original zip file format */ | ||||
|     MZ_ZIP_FLAG_WRITE_ZIP64 = 0x4000,               /* always use the zip64 file format, instead of the original zip file format with automatic switch to zip64. Use as flags parameter with mz_zip_writer_init*_v2 */ | ||||
|     MZ_ZIP_FLAG_WRITE_ALLOW_READING = 0x8000, | ||||
|     MZ_ZIP_FLAG_UTF8_FILENAME = 0x10000 | ||||
|     MZ_ZIP_FLAG_ASCII_FILENAME = 0x10000 | ||||
| } mz_zip_flags; | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| typedef enum { | ||||
|     MZ_ZIP_TYPE_INVALID = 0, | ||||
|     MZ_ZIP_TYPE_USER, | ||||
|     MZ_ZIP_TYPE_MEMORY, | ||||
| @@ -111,8 +111,7 @@ typedef enum | ||||
| } mz_zip_type; | ||||
|  | ||||
| /* miniz error codes. Be sure to update mz_zip_get_error_string() if you add or modify this enum. */ | ||||
| typedef enum | ||||
| { | ||||
| typedef enum { | ||||
|     MZ_ZIP_NO_ERROR = 0, | ||||
|     MZ_ZIP_UNDEFINED_ERROR, | ||||
|     MZ_ZIP_TOO_MANY_FILES, | ||||
| @@ -168,12 +167,33 @@ typedef struct | ||||
|  | ||||
|     mz_file_read_func m_pRead; | ||||
|     mz_file_write_func m_pWrite; | ||||
|     mz_file_needs_keepalive m_pNeeds_keepalive; | ||||
|     void *m_pIO_opaque; | ||||
|  | ||||
|     mz_zip_internal_state *m_pState; | ||||
|  | ||||
| } mz_zip_archive; | ||||
|  | ||||
| typedef struct | ||||
| { | ||||
|     mz_zip_archive *pZip; | ||||
|     mz_uint flags; | ||||
|  | ||||
|     int status; | ||||
| #ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS | ||||
|     mz_uint file_crc32; | ||||
| #endif | ||||
|     mz_uint64 read_buf_size, read_buf_ofs, read_buf_avail, comp_remaining, out_buf_ofs, cur_file_ofs; | ||||
|     mz_zip_archive_file_stat file_stat; | ||||
|     void *pRead_buf; | ||||
|     void *pWrite_buf; | ||||
|  | ||||
|     size_t out_blk_remain; | ||||
|  | ||||
|     tinfl_decompressor inflator; | ||||
|  | ||||
| } mz_zip_reader_extract_iter_state; | ||||
|  | ||||
| /* -------- ZIP reading */ | ||||
|  | ||||
| /* Inits a ZIP archive reader. */ | ||||
| @@ -281,6 +301,12 @@ void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFile | ||||
| mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags); | ||||
| mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags); | ||||
|  | ||||
| /* Extract a file iteratively */ | ||||
| mz_zip_reader_extract_iter_state* mz_zip_reader_extract_iter_new(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags); | ||||
| mz_zip_reader_extract_iter_state* mz_zip_reader_extract_file_iter_new(mz_zip_archive *pZip, const char *pFilename, mz_uint flags); | ||||
| size_t mz_zip_reader_extract_iter_read(mz_zip_reader_extract_iter_state* pState, void* pvBuf, size_t buf_size); | ||||
| mz_bool mz_zip_reader_extract_iter_free(mz_zip_reader_extract_iter_state* pState); | ||||
|  | ||||
| #ifndef MINIZ_NO_STDIO | ||||
| /* Extracts a archive file to a disk file and sets its last accessed and modified times. */ | ||||
| /* This function only extracts files, not archive directory records. */ | ||||
| @@ -322,8 +348,13 @@ mz_bool mz_zip_end(mz_zip_archive *pZip); | ||||
| #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS | ||||
|  | ||||
| /* Inits a ZIP archive writer. */ | ||||
| mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size, mz_uint flags); | ||||
| mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size, mz_uint flags); | ||||
| /*Set pZip->m_pWrite (and pZip->m_pIO_opaque) before calling mz_zip_writer_init or mz_zip_writer_init_v2*/ | ||||
| /*The output is streamable, i.e. file_ofs in mz_file_write_func always increases only by n*/ | ||||
| mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size); | ||||
| mz_bool mz_zip_writer_init_v2(mz_zip_archive *pZip, mz_uint64 existing_size, mz_uint flags); | ||||
|  | ||||
| mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size); | ||||
| mz_bool mz_zip_writer_init_heap_v2(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size, mz_uint flags); | ||||
|  | ||||
| #ifndef MINIZ_NO_STDIO | ||||
| mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning); | ||||
| @@ -337,7 +368,8 @@ mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint f | ||||
| /* Finally, for archives opened using mz_zip_reader_init, the mz_zip_archive's user provided m_pWrite function cannot be NULL. */ | ||||
| /* Note: In-place archive modification is not recommended unless you know what you're doing, because if execution stops or something goes wrong before */ | ||||
| /* the archive is finalized the file's central directory will be hosed. */ | ||||
| mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename, mz_uint flags); | ||||
| mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename); | ||||
| mz_bool mz_zip_writer_init_from_reader_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags); | ||||
|  | ||||
| /* Adds the contents of a memory buffer to an archive. These functions record the current local time into the archive. */ | ||||
| /* To add a directory entry, call this method with an archive name ending in a forwardslash with an empty buffer. */ | ||||
| @@ -346,15 +378,12 @@ mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, c | ||||
|  | ||||
| /* Like mz_zip_writer_add_mem(), except you can specify a file comment field, and optionally supply the function with already compressed data. */ | ||||
| /* uncomp_size/uncomp_crc32 are only used if the MZ_ZIP_FLAG_COMPRESSED_DATA flag is specified. */ | ||||
| mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,  | ||||
| 	mz_uint64 uncomp_size, mz_uint32 uncomp_crc32); | ||||
| 	 | ||||
| mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,  | ||||
| 	mz_uint64 uncomp_size, mz_uint32 uncomp_crc32, MZ_TIME_T *last_modified, const char* user_extra_data_local, mz_uint user_extra_data_local_len, | ||||
| 	const char* user_extra_data_central, mz_uint user_extra_data_central_len); | ||||
| 	 | ||||
|  | ||||
| mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, | ||||
|                                  mz_uint64 uncomp_size, mz_uint32 uncomp_crc32); | ||||
|  | ||||
| mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, | ||||
|                                     mz_uint64 uncomp_size, mz_uint32 uncomp_crc32, MZ_TIME_T *last_modified, const char *user_extra_data_local, mz_uint user_extra_data_local_len, | ||||
|                                     const char *user_extra_data_central, mz_uint user_extra_data_central_len); | ||||
|  | ||||
| #ifndef MINIZ_NO_STDIO | ||||
| /* Adds the contents of a disk file to an archive. This function also records the disk file's modified time into the archive. */ | ||||
| @@ -363,8 +392,8 @@ mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, | ||||
|  | ||||
| /* Like mz_zip_writer_add_file(), except the file data is read from the specified FILE stream. */ | ||||
| mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 size_to_add, | ||||
| 	const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, const char* user_extra_data_local, mz_uint user_extra_data_local_len, | ||||
| 	const char* user_extra_data_central, mz_uint user_extra_data_central_len); | ||||
|                                 const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, const char *user_extra_data_local, mz_uint user_extra_data_local_len, | ||||
|                                 const char *user_extra_data_central, mz_uint user_extra_data_central_len); | ||||
| #endif | ||||
|  | ||||
| /* Adds a file to an archive by fully cloning the data from another archive. */ | ||||
| @@ -396,10 +425,13 @@ mz_bool mz_zip_add_mem_to_archive_file_in_place_v2(const char *pZip_filename, co | ||||
| /* Reads a single file from an archive into a heap block. */ | ||||
| /* If pComment is not NULL, only the file with the specified comment will be extracted. */ | ||||
| /* Returns NULL on failure. */ | ||||
| void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, const char *pComment, size_t *pSize, mz_uint flags, mz_zip_error *pErr); | ||||
| void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags); | ||||
| void *mz_zip_extract_archive_file_to_heap_v2(const char *pZip_filename, const char *pArchive_name, const char *pComment, size_t *pSize, mz_uint flags, mz_zip_error *pErr); | ||||
|  | ||||
| #endif /* #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS */ | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
|  | ||||
| #endif /* MINIZ_NO_ARCHIVE_APIS */ | ||||
|   | ||||
							
								
								
									
										41
									
								
								readme.md
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								readme.md
									
									
									
									
									
								
							| @@ -1,14 +1,37 @@ | ||||
| ## miniz | ||||
| ## Miniz | ||||
|  | ||||
| This is a reorganized version of miniz | ||||
| https://github.com/richgel999/miniz | ||||
| Miniz is a lossless, high performance data compression library in a single source file that implements the zlib (RFC 1950) and Deflate (RFC 1951) compressed data format specification standards. It supports the most commonly used functions exported by the zlib library, but is a completely independent implementation so zlib's licensing requirements do not apply. Miniz also contains simple to use functions for writing .PNG format image files and reading/writing/appending .ZIP format archives. Miniz's compression speed has been tuned to be comparable to zlib's, and it also has a specialized real-time compressor function designed to compare well against fastlz/minilzo. | ||||
|  | ||||
| Basically file since source file has been separated into a more traditional | ||||
| header/source library. This is mainly based off of the organization done for the | ||||
| version in the valve vogl tool. That way the changes could be merged more easily. | ||||
| https://github.com/ValveSoftware/vogl/blob/master/src/voglcore/vogl_miniz.h | ||||
| ## Usage | ||||
|  | ||||
| Please use the files from the [releases page](https://github.com/richgel999/miniz/releases) in your projects. Do not use the git checkout directly! The different source and header files are [amalgamated](https://www.sqlite.org/amalgamation.html) into one `miniz.c`/`miniz.h` pair in a build step (`amalgamate.sh`). Include `miniz.c` and `miniz.h` in your project to use Miniz. | ||||
|  | ||||
| ## Features | ||||
|  | ||||
| * MIT licensed | ||||
| * A portable, single source and header file library written in plain C. Tested with GCC, clang and Visual Studio. | ||||
| * Easily tuned and trimmed down by defines | ||||
| * A drop-in replacement for zlib's most used API's (tested in several open source projects that use zlib, such as libpng and libzip). | ||||
| * Fills a single threaded performance vs. compression ratio gap between several popular real-time compressors and zlib. For example, at level 1, miniz.c compresses around 5-9% better than minilzo, but is approx. 35% slower. At levels 2-9, miniz.c is designed to compare favorably against zlib's ratio and speed. See the miniz performance comparison page for example timings. | ||||
| * Not a block based compressor: miniz.c fully supports stream based processing using a coroutine-style implementation. The zlib-style API functions can be called a single byte at a time if that's all you've got. | ||||
| * Easy to use. The low-level compressor (tdefl) and decompressor (tinfl) have simple state structs which can be saved/restored as needed with simple memcpy's. The low-level codec API's don't use the heap in any way. | ||||
| * Entire inflater (including optional zlib header parsing and Adler-32 checking) is implemented in a single function as a coroutine, which is separately available in a small (~550 line) source file: miniz_tinfl.c | ||||
| * A fairly complete (but totally optional) set of .ZIP archive manipulation and extraction API's. The archive functionality is intended to solve common problems encountered in embedded, mobile, or game development situations. (The archive API's are purposely just powerful enough to write an entire archiver given a bit of additional higher-level logic.) | ||||
|  | ||||
| ## Known Problems | ||||
|  | ||||
| * No support for encrypted archives. Not sure how useful this stuff is in practice. | ||||
| * Minimal documentation. The assumption is that the user is already familiar with the basic zlib API. I need to write an API wiki - for now I've tried to place key comments before each enum/API, and I've included 6 examples that demonstrate how to use the module's major features. | ||||
|  | ||||
| ## Special Thanks | ||||
|  | ||||
| Thanks to Alex Evans for the PNG writer function. Also, thanks to Paul Holden and Thorsten Scheuermann for feedback and testing, Matt Pritchard for all his encouragement, and Sean Barrett's various public domain libraries for inspiration (and encouraging me to write miniz.c in C, which was much more enjoyable and less painful than I thought it would be considering I've been programming in C++ for so long). | ||||
|  | ||||
| Thanks to Bruce Dawson for reporting a problem with the level_and_flags archive API parameter (which is fixed in v1.12) and general feedback, and Janez Zemva for indirectly encouraging me into writing more examples. | ||||
|  | ||||
| ## Patents | ||||
|  | ||||
| I was recently asked if miniz avoids patent issues. miniz purposely uses the same core algorithms as the ones used by zlib. The compressor uses vanilla hash chaining as described [here](http://www.gzip.org/zlib/rfc-deflate.html#algorithm). Also see the [gzip FAQ](http://www.gzip.org/#faq11). In my opinion, if miniz falls prey to a patent attack then zlib/gzip are likely to be at serious risk too. | ||||
|  | ||||
| I've also integrated the changes from here: | ||||
| http://www.tenacioussoftware.com/miniz_v116_beta_r1.7z | ||||
|  | ||||
| [](https://travis-ci.org/uroni/miniz) | ||||
| @@ -993,6 +993,71 @@ static bool zip_extract(const char *pZip_filename, const char *pDst_filename) | ||||
|         } | ||||
|         free(p); | ||||
|     } | ||||
|  | ||||
|     if (stat.m_uncomp_size<100*1024*1024) | ||||
|     { | ||||
|         /* Use iterative reader to read onto heap in one big chunk */ | ||||
|         mz_zip_reader_extract_iter_state *pIter = mz_zip_reader_extract_iter_new(&zip, i, 0); | ||||
|         void *p = malloc(stat.m_uncomp_size); | ||||
|         if ((!pIter) && (0 != stat.m_uncomp_size)) | ||||
|         { | ||||
|             print_error("Failed testing archive -4 \"%s\" err: %s!\n", pZip_filename, mz_zip_get_error_string(mz_zip_get_last_error(&zip))); | ||||
|             free(p); | ||||
|             mz_zip_reader_end(&zip); | ||||
|             return false; | ||||
|         } | ||||
|         if (pIter) | ||||
|         { | ||||
|             if (stat.m_uncomp_size != mz_zip_reader_extract_iter_read(pIter, p, stat.m_uncomp_size) ) | ||||
|             { | ||||
|                 print_error("Failed testing archive -5 \"%s\" err: %s!\n", pZip_filename, mz_zip_get_error_string(mz_zip_get_last_error(&zip))); | ||||
|                 free(p); | ||||
|                 mz_zip_reader_extract_iter_free(pIter); | ||||
|                 mz_zip_reader_end(&zip); | ||||
|                 return false; | ||||
|             } | ||||
|             if (MZ_TRUE != mz_zip_reader_extract_iter_free(pIter)) | ||||
|             { | ||||
|                 print_error("Failed testing archive -6 \"%s\" err: %s!\n", pZip_filename, mz_zip_get_error_string(mz_zip_get_last_error(&zip))); | ||||
|                 free(p); | ||||
|                 mz_zip_reader_end(&zip); | ||||
|                 return false; | ||||
|             } | ||||
|         } | ||||
|         free(p); | ||||
|     } | ||||
|  | ||||
|     if (stat.m_uncomp_size<100*1024) | ||||
|     { | ||||
|         /* Use iterative reader to read file one byte at a time */ | ||||
|         mz_zip_reader_extract_iter_state *pIter = mz_zip_reader_extract_iter_new(&zip, i, 0); | ||||
|         uint8_t byBuffer; | ||||
|         if ((!pIter) && (0 != stat.m_uncomp_size)) | ||||
|         { | ||||
|             print_error("Failed testing archive -7 \"%s\" err: %s!\n", pZip_filename, mz_zip_get_error_string(mz_zip_get_last_error(&zip))); | ||||
|             mz_zip_reader_end(&zip); | ||||
|             return false; | ||||
|         } | ||||
|         if (pIter) | ||||
|         { | ||||
|             for ( uint64_t uiIndex = 0; uiIndex < stat.m_uncomp_size; uiIndex++ ) | ||||
|             { | ||||
|                 if (sizeof(byBuffer) != mz_zip_reader_extract_iter_read(pIter, &byBuffer, sizeof(byBuffer))) | ||||
|                 { | ||||
|                     print_error("Failed testing archive -8 \"%s\" err: %s!\n", pZip_filename, mz_zip_get_error_string(mz_zip_get_last_error(&zip))); | ||||
|                     mz_zip_reader_extract_iter_free(pIter); | ||||
|                     mz_zip_reader_end(&zip); | ||||
|                     return false; | ||||
|                 } | ||||
|             } | ||||
|             if (MZ_TRUE != mz_zip_reader_extract_iter_free(pIter)) | ||||
|             { | ||||
|                 print_error("Failed testing archive -9 \"%s\" err: %s!\n", pZip_filename, mz_zip_get_error_string(mz_zip_get_last_error(&zip))); | ||||
|                 mz_zip_reader_end(&zip); | ||||
|                 return false; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|   } | ||||
|   printf("Verified %u files\n",  mz_zip_reader_get_num_files(&zip)); | ||||
|  | ||||
| @@ -1446,6 +1511,15 @@ static bool test_archives(const char *pPath, comp_options options) | ||||
|         if (mz_crc32(MZ_CRC32_INIT, (const uint8*)p, extracted_size) != extracted_crc32) | ||||
|           status = false; | ||||
|  | ||||
|         mz_zip_reader_extract_iter_state *pIter = mz_zip_reader_extract_file_iter_new(&src_archive, name, 0); | ||||
|         void *q = malloc(extracted_size); | ||||
|         mz_zip_reader_extract_iter_read(pIter, q, extracted_size); | ||||
|         mz_zip_reader_extract_iter_free(pIter); | ||||
|  | ||||
|         if (mz_crc32(MZ_CRC32_INIT, (const uint8*)q, extracted_size) != extracted_crc32) | ||||
|             status = false; | ||||
|  | ||||
|         free(q); | ||||
|         free(p); | ||||
|  | ||||
|         if (options.m_write_archives) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user