~ubuntu-branches/ubuntu/vivid/psi/vivid

« back to all changes in this revision

Viewing changes to iris/xmpp-core/compress.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-08-28 18:46:52 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080828184652-iiik12dl91nq7cdi
Tags: 0.12-2
Uploading to unstable (Closes: Bug#494352)

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
#define CHUNK_SIZE 1024
9
9
 
 
10
static void initZStream(z_stream* z)
 
11
{
 
12
        z->next_in = NULL;
 
13
        z->avail_in = 0;
 
14
        z->total_in = 0;
 
15
        z->next_out = NULL;
 
16
        z->avail_out = 0;
 
17
        z->total_out = 0;
 
18
        z->msg = NULL;
 
19
        z->state = NULL;
 
20
        z->zalloc = Z_NULL;
 
21
        z->zfree = Z_NULL;
 
22
        z->opaque = Z_NULL;
 
23
        z->data_type = Z_BINARY;
 
24
        z->adler = 0;
 
25
        z->reserved = 0;
 
26
}
 
27
 
10
28
Compressor::Compressor(QIODevice* device, int compression) : device_(device)
11
29
{
12
30
        zlib_stream_ = (z_stream*) malloc(sizeof(z_stream));
13
 
        zlib_stream_->zalloc = Z_NULL;
14
 
        zlib_stream_->zfree = Z_NULL;
15
 
        zlib_stream_->opaque = Z_NULL;
 
31
        initZStream(zlib_stream_);
16
32
        int result = deflateInit(zlib_stream_, compression);
17
33
        Q_ASSERT(result == Z_OK);
18
34
        Q_UNUSED(result);
23
39
Compressor::~Compressor()
24
40
{
25
41
        flush();
 
42
        free(zlib_stream_);
26
43
}
27
44
 
28
45
void Compressor::flush()
98
115
Decompressor::Decompressor(QIODevice* device) : device_(device)
99
116
{
100
117
        zlib_stream_ = (z_stream*) malloc(sizeof(z_stream));
101
 
        zlib_stream_->zalloc = Z_NULL;
102
 
        zlib_stream_->zfree = Z_NULL;
103
 
        zlib_stream_->opaque = Z_NULL;
 
118
        initZStream(zlib_stream_);
104
119
        int result = inflateInit(zlib_stream_);
105
120
        Q_ASSERT(result == Z_OK);
106
121
        Q_UNUSED(result);
111
126
Decompressor::~Decompressor()
112
127
{
113
128
        flush();
 
129
        free(zlib_stream_);
114
130
}
115
131
 
116
132
void Decompressor::flush()