Function

compression_encode_buffer

Compresses the contents of a source buffer into a destination buffer.

Declaration

size_t compression_encode_buffer(uint8_t *restrict dst_buffer, size_t dst_size, const uint8_t *restrict src_buffer, size_t src_size, void *restrict scratch_buffer, compression_algorithm algorithm);

Parameters

dst_buffer

Pointer to the buffer that receives the compressed data.

dst_size

Size of the destination buffer in bytes.

src_buffer

Pointer to a buffer containing all of the source data.

src_size

Size of the data in the source buffer in bytes.

scratch_buffer

If scratch_buffer is not nil, this parameter is a pointer to a buffer that the function uses for scratch purposes. The size of this buffer must be at least the size returned by a previous call to compression_encode_scratch_buffer_size.

If scratch_buffer is nil, the function creates and manages its own scratch space, but with a possible performance hit.

algorithm

Return Value

The number of bytes written to the destination buffer after compressing the input. If the funtion can't compress the entire input to fit into the provided destination buffer, or an error occurs, 0 is returned.

Discussion

If the input is successfully compressed, the function writes the compressed data to dst_buffer.

See Also

Single-Step Compression

Compressing and Decompressing Data with Buffer Compression

Compress a string, write it to the file system, and decompress the same file using buffer compression.

compression_encode_scratch_buffer_size

Returns the required compression scratch buffer size for the selected algorithm.

compression_decode_scratch_buffer_size

Returns the required decompression scratch buffer size for the selected algorithm.

compression_decode_buffer

Decompresses the contents of a source buffer into a destination buffer.