Name

inflateEnd — Frees all allocated state information referenced by stream..


Library

Libz.lib


Synopsis

#include <zlib.h>
int inflateEnd(z_streamp stream);


Return Value

On success, inflateEnd() shall return Z_OK. Otherwise it shall return Z_STREAM_ERROR to indicate the error.


Detailed Description

The inflateEnd() function shall free all allocated state information referenced by stream. All pending output is discarded, and unprocessed input is ignored.


Examples

To free all the allocated state information referenced by stream:

#include <stdio.h>
#include <zlib.h>

void Inflateend( )
{
const char hello[] = "hello, hello!";
Byte *compr, *uncompr;
uLong comprLen = 20*sizeof(int);
uLong uncomprLen = comprLen;
compr = (Byte*)calloc((uInt)comprLen, 1);
uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
compress(compr, &comprLen, (const Bytef*)hello, len);
uLong len = (uLong)strlen(hello)+1;
z_stream d_stream; // decompression stream

compress(compr, &comprLen, (const Bytef*)hello, len);
strcpy((char*)uncompr, "garbage");

d_stream.zalloc = (alloc_func)0;
d_stream.zfree = (free_func)0;
d_stream.opaque = (voidpf)0;
d_stream.next_in = compr;
d_stream.avail_in = 0;
d_stream.next_out = uncompr;
err = inflateInit(&d_stream);

while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen)
{
 d_stream.avail_in = d_stream.avail_out = 1; // force small buffers
err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break;
}
inflateEnd(&d_stream);
free(compr);
free(uncompr);
}

Errors

On error, inflateEnd() shall return Z_STREAM_ERROR. The following conditions shall be treated as an error:


Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top