explicit cast zlib functions

This commit is contained in:
2022-07-14 18:39:28 +02:00
parent ddbba7399d
commit eb5b3c8ce2

View File

@@ -10,14 +10,14 @@ namespace utils {
std::uint64_t Inflate(const std::string& source, std::string& dest) {
std::size_t size;
uncompress(reinterpret_cast<Bytef*>(dest.data()), &size, reinterpret_cast<const Bytef*>(source.c_str()), source.length());
uncompress(reinterpret_cast<Bytef*>(dest.data()), reinterpret_cast<uLongf*>(&size), reinterpret_cast<const Bytef*>(source.c_str()), source.length());
return size;
}
std::uint64_t Deflate(const std::string& source, std::string& dest) {
std::size_t size;
dest.resize(source.size()); // Resize for the compressed data to fit into
compress(reinterpret_cast<Bytef*>(dest.data()), &size, reinterpret_cast<const Bytef*>(source.c_str()), source.length());
compress(reinterpret_cast<Bytef*>(dest.data()), reinterpret_cast<uLongf*>(&size), reinterpret_cast<const Bytef*>(source.c_str()), source.length());
dest.resize(size); // Resize to cut useless data
return size;
}