richgel999/miniz
Freeminiz: Single C source file zlib-replacement library, originally from code.google.com/p/miniz
About richgel999/miniz
Miniz is a lossless, high-performance data compression library distributed as a single C source file and header. It implements the zlib (RFC 1950) and Deflate (RFC 1951) compressed data format standards, providing a drop-in replacement for the most commonly used zlib APIs without requiring zlib's license. The library supports stream-based processing via a coroutine-style implementation, allowing data to be compressed or decompressed byte by byte. It also includes simple functions for writing .PNG images and reading/writing/appending .ZIP archives. Miniz's compression speed is tuned to be comparable to zlib, and it offers a specialized real-time compressor that competes well with fastlz and minilzo. The low-level compressor (tdefl) and decompressor (tinfl) use simple state structs that can be saved/restored with memcpy and do not allocate heap memory. The entire inflater is implemented in a single ~550-line coroutine function (miniz_tinfl.c). Miniz is MIT licensed, portable (tested with GCC, Clang, and Visual Studio), and can be easily configured via preprocessor defines.
Key Features
Pros & Cons
- Single-file integration reduces build complexity
- MIT licensed, permissive and no dependency on zlib's license
- Stream-based processing allows handling of data in small chunks
- Low-level API can be used without heap allocation, ideal for constrained environments
- Provides both compression/decompression and archival (ZIP) functionality in one library
- Performance competitive with zlib and faster than minilzo at level 1
- Portable across major compilers and platforms
- Single-threaded only; no built-in parallel compression support
- Compression ratio and speed may not match zlib's heavily optimized implementations at all levels
- Documentation is minimal, relying primarily on the README and source comments
- Limited to zlib/Deflate formats; no support for newer compression standards (e.g., Brotli, Zstd)