qt5base-lts/tests/auto/corelib
Marc Mutz 2fd990b386 Port qCompress() to zstream/deflate()
The zlib convenience API we've been using so far has two problems:

- On Windows-64, where sizeof(long) == 4, the use of ulong for sizes
  meant that we could not compress data compressable on other 64-bit
  platforms (Unix). While zstream also uses ulong, being a stream API,
  it allows feeding data in chunks. The total_in and total_out members
  are only required for gzip compression and are otherwise just
  informational. They're unsigned, so their overflow does not cause
  UB. In summary, using zstream + deflate() allows us to compress more
  than 4GiB of data even on Windows-64.

- On all platforms, we always allocated the output buffer in such a
  way as to accommodate the pathological case of random, incompressible
  data, so the output buffer was larger than the input. Using zstream
  + deflate(), we can start with a smaller buffer, then let zlib pick
  up where it left off when it ran out of output buffer space, saving
  memory in the common case that compression meaningfully reduces the
  size. To avoid the first few rounds of reallocations, we continue to
  use zlib's compressBound() for input less than 256KiB.

This completely fixes the compression side of QTBUG-106542 and
QTBUG-104972.

Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-104972
Fixes: QTBUG-106542
Change-Id: Ia7e6c38403906b35462480fd611b482f05a5c59c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-10-17 23:33:41 +02:00
..
animation Change the license of all CMakeLists.txt and *.cmake files to BSD 2022-08-23 23:58:42 +02:00
global Long live Q_UNREACHABLE_RETURN()! 2022-10-15 22:11:47 +02:00
io Autotest/Unix: request zero-sized core dumps for crashing code 2022-10-14 08:18:53 -07:00
itemmodels Port from qAsConst() to std::as_const() 2022-10-11 23:17:18 +02:00
kernel Port from qAsConst() to std::as_const() 2022-10-11 23:17:18 +02:00
mimetypes Port from container.count()/length() to size() 2022-10-04 07:40:08 +02:00
platform Change the license of all CMakeLists.txt and *.cmake files to BSD 2022-08-23 23:58:42 +02:00
plugin tst_QPlugin::scanInvalidPlugin(): de-duplicate a data-tag 2022-10-11 11:23:40 +02:00
serialization Port from qAsConst() to std::as_const() 2022-10-11 23:17:18 +02:00
text Port qCompress() to zstream/deflate() 2022-10-17 23:33:41 +02:00
thread tst_QAtomicInt:fetchAndAdd(): remove two duplicate data rows 2022-10-17 15:53:32 +02:00
time tst_QTime: fix two duplicated test data tags 2022-10-17 15:53:32 +02:00
tools tst_Q{BitArray,ContiguousCache}: check not only count(), but size(), too 2022-10-17 19:33:34 +02:00
CMakeLists.txt Change the license of all CMakeLists.txt and *.cmake files to BSD 2022-08-23 23:58:42 +02:00