Name

compressBound Estimates the size of buffer required to compress sourceLen   bytes of data using the compress() or compress2() functions.


Library

Libz.lib


Synopsis

#include <zlib.h>
int compressBound(uLong sourceLen);
 


Return Value

The compressBound() shall return a value representing the upper bound of an array to allocate to hold the compressed data in a single call to compress() or compress2(). This function may return a conservative value that may be larger than sourceLen.

Detailed Description

The compressBound() function shall estimate the size of buffer required to compress sourceLen bytes of data using the compress() or compress2( ) functions. If successful, the value returned shall be an upper bound for the size of buffer required to compress sourceLen bytes of data, using the parameters stored in stream, in a single call to compress() or compress2().


Examples

To estimate the size of buffer required to compress 6 bytes of data:

#include <stdio.h>
#include <zlib.h>
void test_compressbound(Byte * compr,uLong comprLen)

    uLong sourceLen = (uLong)strlen(hello)+1;
    const char hello[] = "hello, hello!";
    compress(compr, &comprLen, (const Bytef*)hello, 6);
    int x =  compressBound(sourceLen);
    printf("size of buffer required is %d",x);
}

Output

size of buffer required is 25. 

Errors

None defined.


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.