I have a small buffer with some data (ca. 35’000 bytes).
No i would like to inflate my buffer with zlib.
The buffer is named “pos_in_mem” (void *) and the length of my buffer is len (int *).
I always get a -3 (Z_DATA_ERROR) on that part of code:
int ret;
z_stream strm;
unsigned char in[CHUNK];
unsigned char out[CHUNK];
/* allocate deflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit(&strm);
if (ret != Z_OK) {
printf("zlib init failed");
}
strm.avail_in = *len; // this is my buffer length
strm.next_in = pos_in_mem; // this is my buffer
strm.avail_out = CHUNK;
strm.next_out = out;
//ret = deflate(&strm, flush);
ret = inflate(&strm, Z_NO_FLUSH); // here i always get a -3 Z_DATA_ERROR
printf("%d", strm.avail_out);
(void)inflateEnd(&strm);
any ideas?
Thanks
You probably mistook
inflatewithdeflate.inflate– inflation, rise of volume, decompressdeflate– deflation, decrease of volume, compressGood
deflate/inflateexamples on zlib web page.