diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-03-28 13:40:14 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-03-28 13:40:43 (GMT) |
commit | b61486fefe602e0d18fa5279021006f87b965307 (patch) | |
tree | 437585cbef1179e1ec31f79789591d5610200c29 /Swiften/Compress/ZLibCodecompressor.cpp | |
parent | dae28dd45e43fc6e6ef2ec4c6c65d5d736ed86f8 (diff) | |
download | swift-contrib-b61486fefe602e0d18fa5279021006f87b965307.zip swift-contrib-b61486fefe602e0d18fa5279021006f87b965307.tar.bz2 |
Moved Swiften to a separate module.
Diffstat (limited to 'Swiften/Compress/ZLibCodecompressor.cpp')
m--------- | Swiften | 0 | ||||
-rw-r--r-- | Swiften/Compress/ZLibCodecompressor.cpp | 43 |
2 files changed, 0 insertions, 43 deletions
diff --git a/Swiften b/Swiften new file mode 160000 +Subproject 8213ba16d0043d2461f4b031c881d61dda5a38c diff --git a/Swiften/Compress/ZLibCodecompressor.cpp b/Swiften/Compress/ZLibCodecompressor.cpp deleted file mode 100644 index a14f09d..0000000 --- a/Swiften/Compress/ZLibCodecompressor.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "Swiften/Compress/ZLibCodecompressor.h" - -#include <cassert> - -#include "Swiften/Compress/ZLibException.h" - -namespace Swift { - -static const int CHUNK_SIZE = 1024; // If you change this, also change the unittest - -ZLibCodecompressor::ZLibCodecompressor() { - stream_.zalloc = Z_NULL; - stream_.zfree = Z_NULL; - stream_.opaque = Z_NULL; -} - -ZLibCodecompressor::~ZLibCodecompressor() { -} - -ByteArray ZLibCodecompressor::process(const ByteArray& input) { - ByteArray output; - stream_.avail_in = input.getSize(); - stream_.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(input.getData())); - int outputPosition = 0; - do { - output.resize(outputPosition + CHUNK_SIZE); - stream_.avail_out = CHUNK_SIZE; - stream_.next_out = reinterpret_cast<Bytef*>(output.getData() + outputPosition); - int result = processZStream(); - if (result != Z_OK && result != Z_BUF_ERROR) { - throw ZLibException(/* stream_.msg */); - } - outputPosition += CHUNK_SIZE; - } - while (stream_.avail_out == 0); - if (stream_.avail_in != 0) { - throw ZLibException(); - } - output.resize(outputPosition - stream_.avail_out); - return output; -} - -} |