60 #include "../DataCompressionLayer.hpp" 61 #include "../ByteUtilities.hpp" 71 int inf(FILE *source, FILE *dest);
77 for (
int i = 0; i < size;i++) {
81 cout <<
"Compressed " << size <<
" longs ("<< size*8<<
" bytes). The compressed size is " << compr.
getOutputLength() << endl;
84 FILE* tmp1 = tmpfile();
87 FILE* tmp2 = tmpfile();
91 for (
int i = 0; i < size;i++) {
92 long checkval = rand();
94 fread(&b[0],
sizeof(
char), 8, tmp2);
95 long readval = ByteUtilities::readLong(b);
96 assert(checkval == readval);
98 cout <<
"Compression correctness verified."<<endl;
106 int inf(FILE *source, FILE *dest)
112 unsigned char in[
CHUNK];
113 unsigned char out[
CHUNK];
116 strm.zalloc = Z_NULL;
118 strm.opaque = Z_NULL;
120 strm.next_in = Z_NULL;
121 ret = inflateInit(&strm);
128 if (ferror(source)) {
129 (void)inflateEnd(&strm);
132 if (strm.avail_in == 0)
138 strm.avail_out =
CHUNK;
140 ret = inflate(&strm, Z_NO_FLUSH);
141 assert(ret != Z_STREAM_ERROR);
147 (void)inflateEnd(&strm);
150 have =
CHUNK - strm.avail_out;
151 if (
fwrite(out, 1, have, dest) != have || ferror(dest)) {
152 (void)inflateEnd(&strm);
155 }
while (strm.avail_out == 0);
158 }
while (ret != Z_STREAM_END);
161 (void)inflateEnd(&strm);
162 return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
unsigned char * getOutputBuffer()
size_t MONITOR_EXT_WRAP_NAME() fread(void *ptr, size_t size, size_t count, FILE *stream)
int inf(FILE *source, FILE *dest)
size_t MONITOR_EXT_WRAP_NAME() fwrite(const void *ptr, size_t size, size_t count, FILE *stream)