From 3790d1da0d338c9fbc192ab845d3c521a523dd26 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 23 Oct 2019 08:45:30 -0400 Subject: [PATCH] Use zlib types for string::compress/uncompress implementation. --- src/string.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/string.cpp b/src/string.cpp index 4de82dd0..493c9abf 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -249,7 +249,7 @@ std::vector fromBase64(const std::string& str) { std::vector compress(const uint8_t* data, size_t dataLen) { std::vector compressed; - size_t outCap = ::compressBound(dataLen); + uLongf outCap = ::compressBound(dataLen); compressed.resize(outCap); int err = ::compress2(compressed.data(), &outCap, data, dataLen, Z_BEST_COMPRESSION); if (err) @@ -265,8 +265,10 @@ std::vector compress(const std::vector& data) { void uncompress(const uint8_t* compressed, size_t compressedLen, uint8_t* data, size_t* dataLen) { - int err = ::uncompress(data, dataLen, compressed, compressedLen); + uLongf dataLenF = *dataLen; + int err = ::uncompress(data, &dataLenF, compressed, compressedLen); (void) err; + *dataLen = dataLenF; }