Reputation: 11
I am using zlib-1.2.8 and I am calling compress2(dest, destLen, source, sourceLen, level)
from compress.c in my code for compressing the data.
The function compress2 (dest, destLen, source, sourceLen, level)
is calling
deflateInit(&stream, level);
deflateInit is macro.
#define deflateInit(strm, level) \
deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
That is compress2 is calling deflateInit_.
My Problem is deflateInit_ is returning Z_MEM_ERROR
.
I am trying to debug inside deflateInit_ but not got any debug messages that I have put there.
Also I commented all the exising code inside function deflateInit_ and return different error from the function ie Z_BUF_ERROR
but still deflateInit_ is returning Z_MEM_ERROR
.
Here if I am explicty returing Z_BUF_ERROR
still I am getting Z_MEM_ERROR
.
Please give me some pointers behind this behaviour.
Upvotes: 0
Views: 1738
Reputation: 112374
It means what it says. zlib is calling malloc()
, which is returning NULL
. That is presumably because there is not enough memory availabel to malloc()
to honor the request. deflate with the default parameters needs to allocate about 260K to function.
Upvotes: 1