Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/coding
diff options
context:
space:
mode:
authorYuri Gorshenin <y@maps.me>2017-01-30 13:18:08 +0300
committerYuri Gorshenin <y@maps.me>2017-01-30 14:06:54 +0300
commit39b800ec8655d443b23b5ec1c05f47dd1771f770 (patch)
tree6e343afd50df72ed15bf6728a7757e5be6668496 /coding
parentc0a9fbc742d200e447670d89cd5067d14f8e9d9a (diff)
[coding] Fixed ZLib wrappers.
Diffstat (limited to 'coding')
-rw-r--r--coding/zlib.cpp8
-rw-r--r--coding/zlib.hpp15
2 files changed, 19 insertions, 4 deletions
diff --git a/coding/zlib.cpp b/coding/zlib.cpp
index f54cc574b4..2d40bbcebe 100644
--- a/coding/zlib.cpp
+++ b/coding/zlib.cpp
@@ -57,6 +57,14 @@ ZLib::DeflateProcessor::DeflateProcessor(void const * data, size_t size, ZLib::L
ZLib::DeflateProcessor::~DeflateProcessor() noexcept
{
+ unsigned bytes = 0;
+ int bits = 0;
+ int const ret = deflatePending(&m_stream, &bytes, &bits);
+ UNUSED_VALUE(ret);
+ ASSERT_EQUAL(ret, Z_OK, (""));
+ ASSERT_EQUAL(bytes, 0, ("Some bytes were not flushed:", bytes));
+ ASSERT_EQUAL(bits, 0, ("Some bits were not flushed:", bits));
+
if (m_init)
deflateEnd(&m_stream);
}
diff --git a/coding/zlib.hpp b/coding/zlib.hpp
index ee6775563b..dba1a59ec7 100644
--- a/coding/zlib.hpp
+++ b/coding/zlib.hpp
@@ -118,12 +118,19 @@ private:
while (true)
{
int const flush = processor.ConsumedAll() ? Z_FINISH : Z_NO_FLUSH;
- int const ret = processor.Process(flush);
- if (ret != Z_OK && ret != Z_STREAM_END)
- return false;
+ int ret = Z_OK;
+
+ while (true)
+ {
+ ret = processor.Process(flush);
+ if (ret != Z_OK && ret != Z_STREAM_END)
+ return false;
+
+ if (!processor.BufferIsFull())
+ break;
- if (processor.BufferIsFull())
processor.MoveOut(out);
+ }
if (flush == Z_FINISH && ret == Z_STREAM_END)
break;