X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcommon%2Fcompressor.cpp;h=2b91bebe78a9584da8f6fb0c8df0462889f9fa9a;hb=39328183a6a87c6eb10a9dbbffcd5d65bf154a1f;hp=d2634e481e3d92241a0e59d5a514520c2a47ee8c;hpb=bdb3b8a3086fcd871d2a099fa4a40376f4040e6e;p=quassel.git diff --git a/src/common/compressor.cpp b/src/common/compressor.cpp index d2634e48..2b91bebe 100644 --- a/src/common/compressor.cpp +++ b/src/common/compressor.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2014 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -23,9 +23,6 @@ #include #include -#define MINIZ_HEADER_FILE_ONLY -#include "../../3rdparty/miniz/miniz.c" - const int maxBufferSize = 64 * 1024 * 1024; // protect us from zip bombs const int ioBufferSize = 64 * 1024; // chunk size for inflate/deflate; should not be too large as we preallocate that space! @@ -33,8 +30,8 @@ Compressor::Compressor(QTcpSocket *socket, Compressor::CompressionLevel level, Q : QObject(parent), _socket(socket), _level(level), - _inflater(0), - _deflater(0) + _inflater(nullptr), + _deflater(nullptr) { connect(socket, SIGNAL(readyRead()), SLOT(readData())); @@ -93,7 +90,7 @@ bool Compressor::initStreams() _deflater = new z_stream; memset(_deflater, 0, sizeof(z_stream)); if (Z_OK != deflateInit(_deflater, zlevel)) { - qWarning() << "Could not intialize the deflate stream!"; + qWarning() << "Could not initialize the deflate stream!"; return false; } @@ -176,7 +173,7 @@ void Compressor::readData() _readBuffer.resize(_readBuffer.size() + ioBufferSize); _inputBuffer.append(_socket->read(ioBufferSize - _inputBuffer.size())); - _inflater->next_in = reinterpret_cast(_inputBuffer.constData()); + _inflater->next_in = reinterpret_cast(_inputBuffer.data()); _inflater->avail_in = _inputBuffer.size(); _inflater->next_out = reinterpret_cast(_readBuffer.data() + _readBuffer.size() - ioBufferSize); _inflater->avail_out = ioBufferSize; @@ -186,7 +183,7 @@ void Compressor::readData() int status = inflate(_inflater, Z_SYNC_FLUSH); // get as much data as possible // adjust input and output buffers - _readBuffer.resize(_inflater->next_out - reinterpret_cast(_readBuffer.constData())); + _readBuffer.resize(_inflater->next_out - reinterpret_cast(_readBuffer.data())); if (_inflater->avail_in > 0) memmove(_inputBuffer.data(), _inflater->next_in, _inflater->avail_in); _inputBuffer.resize(_inflater->avail_in); @@ -225,7 +222,7 @@ void Compressor::writeData() return; } - _deflater->next_in = reinterpret_cast(_writeBuffer.constData()); + _deflater->next_in = reinterpret_cast(_writeBuffer.data()); _deflater->avail_in = _writeBuffer.size(); int status; @@ -239,7 +236,7 @@ void Compressor::writeData() return; } - if (_deflater->avail_out == ioBufferSize) + if (_deflater->avail_out == static_cast(ioBufferSize)) continue; // nothing to write here if (!_socket->write(_outputBuffer.constData(), ioBufferSize - _deflater->avail_out)) {