API Description
KZstar supports only block compression and decompression algorithms and only compression levels 1 to 4. Other levels are processed as level 5. For details about the available APIs, see Table 1.
API Definition |
Description |
Input Parameter |
Return Value |
|---|---|---|---|
size_t ZSTD_compressBound(size_t srcSize); |
Calculates the maximum destination buffer size required after compression based on the input data size. |
srcSize: input data size (in bytes) |
Maximum number of bytes after compression, that is, the buffer size required for compression |
unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize); |
Obtains the original size of a compressed data frame. |
|
Content size (in bytes) of a compressed data frame |
ZSTD_CCtx* ZSTD_createCCtx(void); |
Creates and initializes a compression context, which is used to control parameters in the compression process. |
- |
Pointer to the compression context |
size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); |
Releases the compression context created by ZSTD_createCCtx and related resources. |
cctx: pointer to the compression context to be released |
|
size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize, int compressionLevel); |
Uses the given compression context cctx to compress data. The compression level is configurable. |
|
Actual size of the data that is compressed |
size_t ZSTD_compress(void* dst, size_t dstCapacity, const void* src, size_t srcSize, int compressionLevel); |
Uses the default compression settings to compress data. |
|
Actual size of the data that is compressed |
ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem); |
Creates a decompression context and allows custom memory allocation and release functions to be passed in. |
customMem: custom memory allocation function |
Pointer to the decompression context |
ZSTD_DCtx* ZSTD_createDCtx(void); |
Creates and initializes a decompression context and uses the default memory allocation mode. |
- |
Pointer to the decompression context |
size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); |
Releases the decompression context created by ZSTD_createDCtx or ZSTD_createDCtx_advanced. |
dctx: pointer to the decompression context |
|
size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); |
Uses the created decompression context dctx to decompress the compressed data. |
|
Number of bytes after decompression. If an error occurs, a negative value is returned. |
size_t ZSTD_decompress(void* dst, size_t dstCapacity, const void* src, size_t srcSize); |
Uses the default decompression settings to decompress data. |
|
Number of bytes after decompression. If an error occurs, a negative value is returned. |