Name

deflateCopy Copies the compression state information in source to the uninitialized z_stream structure referenced by dest.


Library

Libz.lib


Synopsis

#include <zlib.h>
int deflateCopy(z_streamp dest, z_streamp source);


Return Value

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

Detailed 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.


Examples

To copy the compression state information in source to the uninitialized z_stream structure referenced by dest.

#include <stdio.h> 
#include <zlib.h>
void Deflatecopy( )
{
    uLong sourceLen = (uLong)strlen(hello)+1;
    z_stream stream;
    z_stream stream1;
    Byte *compr, *uncompr;
    Bytef *dest,  uLongf *destLen ;
    uLong comprLen = 20*sizeof(int);
    uLong uncomprLen = comprLen;
    int level=Z_DEFAULT_COMPRESSION;
    const char hello[] = "hello, hello!";
    compr = (Byte*)calloc((uInt)comprLen, 1);
    uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
   
stream.zalloc = (alloc_func)0;
    stream.zfree = (free_func)0;
    stream.opaque = (voidpf)0;
    stream.next_in = (Bytef*)hello;
    stream.avail_in = (uInt)sourceLen;
    stream.next_out = dest;
    stream.avail_out = (uInt)*destLen;
 
  deflateInit(&stream, level);
    deflateCopy(&stream1 , &stream);
    deflateEnd(&stream);
}

Output

Now stream1 and stream are in same state.

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.


Feedback

For additional information or queries on this page send feedback


© 2007-2009 Nokia Corporation. All rights reserved. This documentation can be used in the connection with this Product to help and support the user.