deflateCopy

Name

deflateCopy -- copy compression stream

Synopsis

#include <zlib.h>

int deflateCopy(z_streamp dest, z_streamp source);

Description

The deflateCopy() function shall copy the compression state information in source to the uninitialized z_stream structure referenced by dest.

On successful return, dest will be an exact copy of the stream referenced by source. The input and output buffer pointers in next_in and next_out will reference the same data.

Return Value

On success, deflateCopy() shall return Z_OK. Otherwise it shall return a value less than zero to indicate the error.

Errors

On error, deflateCopy() shall return a value as described below:

Z_STREAM_ERROR 

The state in source is inconsistent, or either source or dest was NULL.

Z_MEM_ERROR 

Insufficient memory available.

Application Usage (informative)

This function can be useful when several compression strategies will be tried, for example when there are several ways of pre-processing the input data with a filter. The streams that will be discarded should then be freed by calling deflateEnd(). Note that deflateCopy() duplicates the internal compression state which can be quite large, so this strategy may be slow and can consume lots of memory.