# CreateDecompressor

Creates a decompression engine.

### Synopsis

`Err CreateDecompressor(Decompressor **comp, CompFunc cf,const TagArg *tags);
Err CreateDecompressorVA(Decompressor **comp, CompFunc cf,uint32 tags, ...);`

### Description

Creates a decompression engine. Once the engine is created, you can call `FeedDecompressor()` to have the engine decompress the data you supply.

### Arguments

decomp
  A pointer to a decompressor variable, where a handle to the decompression engine can be put.

cf
  A data output function. Every word of decompressed 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 decompressed data being output by the decompressor.

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 decompressor 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 GetDecompressorWorkBufferSize() function. The buffer you supply must be aligned on a 4-byte boundary, and must remain valid until DeleteDecompressor() is called. When you supply a work buffer, this routine allocates no memory of its own.

COMP_TAG_USERDATA(void *)
  A value that the decompressor 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 decompression 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

``FeedDecompressor`(), DeleteDecompressor(), GetDecompressorWorkBufferSize(), CreateCompressor()`