Name

inflateInit2_ — Initializes the decompression system.


Library

Libz.lib


Synopsis

#include <zlib.h>
int inflateInit2_ (z_streamp strm, int windowBits, char * version,int stream_size);


Return Value

On success, the inflateInit2_() function shall return Z_OK. Otherwise, inflateInit2_() shall return a value as described below to indicate the error.


Detailed Description

The inflateInit2_() function shall initialize the decompression system. On entry, strm shall refer to a user supplied z_stream object (a z_stream_s structure). The following fields shall be set on entry:

zalloc  

a pointer to an alloc_func function, used to allocate state information. If this is NULL, a default allocation function will be used.

zfree  

a pointer to a free_func function, used to free memory allocated by the zalloc function. If this is NULL a default free function will be used.

opaque  

If alloc_func is not NULL, opaque is a user supplied pointer to data that will be passed to the alloc_func and free_func functions.

If the version requested is not compatible with the version implemented, or if the size of the z_stream_s structure provided in stream_size does not match the size in the library implementation, inflateInit2_() shall fail, and return Z_VERSION_ERROR.

The windowBits parameter shall be a base 2 logarithm of the maximum window size to use, and shall be a value between 8 and 15. If the input data was compressed with a larger window size, subsequent attempts to decompress this data will fail with Z_DATA_ERROR, rather than try to allocate a larger window.

The inflateInit2_() function is not in the source standard; it is only in the binary standard. Source applications should use the inflateInit2() macro.


Examples

To initialize the decompression system with windowBits=15:

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

void InflateInit2_( )
{
z_stream d_stream; // decompression stream
const char * version;
d_stream.zalloc = (alloc_func)0;
d_stream.zfree = (free_func)0;
d_stream.opaque = (voidpf)0;
version = zlibVersion();
int ret = inflateInit2_(&d_stream,15,version, sizeof(d_stream));
inflateEnd(&d_stream);
}


Errors

On error, inflateInit2_() shall return one of the following error indicators:

Z_STREAM_ERROR

Invalid parameter.

Z_MEM_ERROR

Insufficient memory available.

Z_VERSION_ERROR

The version requested is not compatible with the library version, or the z_stream size differs from that used by the library.

In addition, the msg field of the strm may be set to an error message.


Feedback

For additional information or queries on this page send feedback


© 2005-2007 Nokia

Top