CreateCompressor

Creates a compression engine.

Synopsis

Err CreateCompressor(Compressor **comp, CompFunc cf,const TagArg *tags);
Err CreateCompressorVA(Compressor **comp, CompFunc cf,uint32 tags, ...);

Description

Creates a compression engine. Once the engine is created, you can call FeedCompressor() to have the engine compress the data you supply.

Arguments

comp
A pointer to a compressor variable, where a handle to the compression engine can be put.
cf
A data output function. Every word of compressed data is sent to this function. This function is called with two parameters: one is a user-data value as supplied with the COMP_TAG_USERDATA tag. The other is the word of compressed data being output by the compressor.
tags
A pointer to an array of tag arguments containing extra data for this function. See below for a description of the tags supported.

Tag Arguments

The following tag arguments may be supplied in array form to this function. The array must be terminated with TAG_END.

COMP_TAG_WORKBUFFER(void *)
A pointer to a work buffer. This buffer is used by the compressor to store state information. If this tag is not supplied, the buffer is allocated and freed by the folio automatically. To obtain the required size for the buffer, call the GetCompressorWorkBufferSize() function. The buffer you supply must be aligned on a 4-byte boundary, and must remain valid until DeleteCompressor() is called. When you supply a work buffer, this routine allocates no memory of its own.
COMP_TAG_USERDATA(void *)
A value that the compressor will pass to cf when it is called. This value can be anything you want. For example, it can be a pointer to a private data structure containing some context such as a file handle. If this tag is not supplied, then NULL is passed to cf when it is called.

Return Value

Returns >= 0 for success, or a negative error code if the compression engine could not be created. Possible error codes include:

COMP_ERR_BADPTR
An invalid output function pointer or work buffer was supplied.
COMP_ERR_BADTAG
An unknown tag was supplied.
COMP_ERR_NOMEM
There was not enough memory to initialize the compressor.

Implementation

Folio call implemented in compression folio V24.

Associated Files

compression.h

See Also

FeedCompressor(), DeleteCompressor(), GetCompressorWorkBufferSize(), CreateDecompressor()