diff --git a/include/msgpack/zbuffer.h b/include/msgpack/zbuffer.h index dbad72c5..dbad8591 100644 --- a/include/msgpack/zbuffer.h +++ b/include/msgpack/zbuffer.h @@ -131,7 +131,7 @@ int msgpack_zbuffer_write(void* data, const char* buf, size_t len) zbuf->stream.next_in = (Bytef*)buf; zbuf->stream.avail_in = len; - do { + while(zbuf->stream.avail_in > 0) { if(zbuf->stream.avail_out < MSGPACK_ZBUFFER_RESERVE_SIZE) { if(!msgpack_zbuffer_expand(zbuf)) { return -1; @@ -141,7 +141,7 @@ int msgpack_zbuffer_write(void* data, const char* buf, size_t len) if(deflate(&zbuf->stream, Z_NO_FLUSH) != Z_OK) { return -1; } - } while(zbuf->stream.avail_in > 0); + } return 0; } diff --git a/include/msgpack/zbuffer.hpp b/include/msgpack/zbuffer.hpp index 688a70b5..71880648 100644 --- a/include/msgpack/zbuffer.hpp +++ b/include/msgpack/zbuffer.hpp @@ -65,7 +65,7 @@ public: m_stream.next_in = reinterpret_cast(const_cast(buf)); m_stream.avail_in = len; - do { + while(m_stream.avail_in > 0) { if(m_stream.avail_out < MSGPACK_ZBUFFER_RESERVE_SIZE) { if(!expand()) { throw std::bad_alloc(); @@ -75,7 +75,7 @@ public: if(deflate(&m_stream, Z_NO_FLUSH) != Z_OK) { throw std::bad_alloc(); } - } while(m_stream.avail_in > 0); + } } char* flush()