API for compressors and decompressors of binary buffers.
typedef bool(* CPLCompressionFunc) (const void *input_data, size_t input_size, void **output_data, size_t *output_size, CSLConstList options, void *compressor_user_data) |
Callback of a compressor/decompressor.
For a compressor, input is uncompressed data, and output compressed data. For a decompressor, input is compressed data, and output uncompressed data.
Valid situations for output_data and output_size are:
-
output_data != NULL and *output_data != NULL and output_size != NULL and *output_size != 0. The caller provides the output buffer in *output_data and its size in *output_size. In case of successful operation, *output_size will be updated to the actual size. This mode is the one that is always guaranteed to be implemented efficiently. In case of failure due to insufficient space, it will be updated to the size needed (if known), or 0 (if unknown)
-
output_data == NULL and output_size != NULL. *output_size will be updated with the minimum size the output buffer should be (if known), or 0 (if unknown).
-
output_data != NULL and *output_data == NULL and output_size != NULL. *output_data will be allocated using VSIMalloc(), and should be freed by the caller with VSIFree(). *output_size will be updated to the size of the output buffer.
- Parameters
-
input_data | Input data. Should not be NULL. |
input_size | Size of input data, in bytes. |
output_data | Pointer to output data. |
output_size | Pointer to output size. |
options | NULL terminated list of options. Or NULL. |
compressor_user_data | User data provided at registration time. |
- Returns
- true in case of success.