fix: COMPRESSION

This commit is contained in:
2023-01-01 19:40:23 +01:00
parent 4e8b095e31
commit 019174128c

View File

@@ -9,13 +9,13 @@ namespace td {
namespace utils {
std::uint64_t Inflate(const std::string& source, std::string& dest) {
std::size_t size;
uLongf size = dest.size();
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;
uLongf size = source.length();
dest.resize(source.size()); // Resize for the compressed data to fit into
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