compress

Name

compress -- compress data

Synopsis

#include <zlib.h>

int compress(Bytef * dest, uLongf * destLen, const Bytef * source, uLong sourceLen);

Description

The compress() function shall attempt to compress sourceLen bytes of data in the buffer source, placing the result in the buffer dest.

On entry, destLen should point to a value describing the size of the dest buffer. The application should ensure that this value be at least (sourceLen × 1.001) + 12. On successful exit, the variable referenced by destLen shall be updated to hold the length of compressed data in dest.

The compress() function is equivalent to compress2() with a level of Z_DEFAULT_LEVEL.

Return Value

On success, compress() shall return Z_OK. Otherwise, compress() shall return a value to indicate the error.

Errors

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

Z_BUF_ERROR 

The buffer dest was not large enough to hold the compressed data.

Z_MEM_ERROR 

Insufficient memory.