src/native/external/zlib-ng/PORTING.md
Zlib-ng can be used/compiled in two different modes, that require some consideration by the application developer.
Zlib-ng is not as conservative with memory allocation as Zlib is.
Where Zlib's inflate will allocate a lower amount of memory depending on compression level and window size, zlib-ng will always allocate the maximum amount of memory and possibly leave parts of it unused. Zlib-ng's deflate will however allocate a lower amount of memory depending on compression level and window size.
Zlib-ng also allocates one "big" buffer instead of doing multiple smaller allocations. This is faster, can lead to better cache locality and reduces space lost to alignment padding.
At the time of writing, by default zlib-ng allocates the following amounts of memory on a 64-bit system (except on S390x that requires ~4KiB more):
Advantages:
Disadvantages:
Zlib-ng can be compiled in zlib-compat mode, suitable for zlib-replacement in a single application or system-wide.
Please note that zlib-ng in zlib-compat mode tries to maintain both API and ABI compatibility with the original zlib. Any issues regarding compatibility can be reported as bugs.
In certain instances you may not be able to simply replace the zlib library/dll files and expect the application to work. The application may need to be recompiled against the zlib-ng headers and libs to ensure full compatibility.
It is also possible for the deflate output stream to differ from the original zlib due to algorithmic differences between the two libraries. Any tests or applications that depend on the exact length of the deflate stream being a certain value will need to be updated.
Advantages:
Disadvantages:
Build Considerations:
z_size_t is unsigned __int64 on 64-bit Windows, and unsigned long on 32-bit Windows, Unix and macOSz_uintmax_t is unsigned long in zlib-compat mode, and size_t with zlib-ng APIZlib-ng in native mode is suitable for co-existing with the standard zlib library, allowing applications to implement support and testing separately.
The zlib-ng native has implemented some modernization and simplifications in its API, intended to make life easier for application developers.
Advantages:
Disadvantages:
zng_ has to be added.Build Considerations:
z_size_t is size_tTo distinguish zlib-ng from other zlib implementations at compile-time check for the
existence of ZLIBNG_VERSION defined in the zlib header.