From 9cb4c8073edea87d52bd0cf88f2317ead353eec2 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Sun, 2 Sep 2012 09:14:55 -0700 Subject: Fixing ZHandle, and adding a unit test for it. --- src/ZHandle.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ZHandle.cc b/src/ZHandle.cc index 4f216c7..aa7bde7 100644 --- a/src/ZHandle.cc +++ b/src/ZHandle.cc @@ -22,14 +22,14 @@ Balau::ZStream::ZStream(const IO & h, int level, header_t header) : m_h( } void Balau::ZStream::close() throw (GeneralException) { - if (m_in) { - free(m_in); - m_in = NULL; - } if (m_h->canWrite()) finish(); inflateEnd(&m_zin); deflateEnd(&m_zout); + if (m_in) { + free(m_in); + m_in = NULL; + } if (!m_detached) m_h->close(); m_closed = true; @@ -78,6 +78,7 @@ ssize_t Balau::ZStream::read(void * buf, size_t count) throw (GeneralException) size_t r = m_h->read(m_in, BLOCK_SIZE); if (r <= 0) return readTotal; + m_zin.avail_in = r; } Task::operationYield(); int r = inflate(&m_zin, Z_SYNC_FLUSH); -- cgit v1.2.3