39#define MIN_COMP_LEVEL 1
40#define MAX_COMP_LEVEL 22
86 cdata->
cctx = ZSTD_createCCtx();
87 cdata->
dctx = ZSTD_createDCtx();
92 ZSTD_freeCCtx(cdata->
cctx);
93 ZSTD_freeDCtx(cdata->
dctx);
116 size_t dlen,
size_t *clen)
124 size_t len = ZSTD_compressBound(dlen);
127 size_t rc = ZSTD_compressCCtx(cdata->
cctx, cdata->
buf, len, data, dlen, cdata->
level);
128 if (ZSTD_isError(rc))
147 unsigned long long len = ZSTD_getFrameContentSize(cbuf, clen);
148 if (len == ZSTD_CONTENTSIZE_UNKNOWN)
150 else if (len == ZSTD_CONTENTSIZE_ERROR)
156 size_t rc = ZSTD_decompressDCtx(cdata->
dctx, cdata->
buf, len, cbuf, clen);
157 if (ZSTD_isError(rc))
175 ZSTD_freeCCtx(cdata->
cctx);
178 ZSTD_freeDCtx(cdata->
dctx);
void ComprHandle
Opaque type for compression data.
const struct ComprOps compr_zstd_ops
#define COMPRESS_OPS(_name, _min_level, _max_level)
static void compr_zstd_close(ComprHandle **ptr)
Close a compression context - Implements ComprOps::close() -.
static void * compr_zstd_compress(ComprHandle *handle, const char *data, size_t dlen, size_t *clen)
Compress header cache data - Implements ComprOps::compress() -.
static void * compr_zstd_decompress(ComprHandle *handle, const char *cbuf, size_t clen)
Decompress header cache data - Implements ComprOps::decompress() -.
static ComprHandle * compr_zstd_open(short level)
Open a compression context - Implements ComprOps::open() -.
#define mutt_debug(LEVEL,...)
@ LL_DEBUG1
Log at debug level 1.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
void mutt_mem_realloc(void *pptr, size_t size)
Resize a block of memory on the heap.
#define MUTT_MEM_CALLOC(n, type)
Convenience wrapper for the library headers.
const char * name
Compression name.
Private Zstandard Compression Data.
short level
Compression Level to be used.
ZSTD_CCtx * cctx
Compression context.
ZSTD_DCtx * dctx
Decompression context.
void * buf
Temporary buffer.
void zstd_cdata_free(struct ZstdComprData **ptr)
Free Zstandard Compression Data.
static struct ZstdComprData * zstd_cdata_new(void)
Create new Zstandard Compression Data.
#define MAX_COMP_LEVEL
Maximum compression level for zstd.
#define MIN_COMP_LEVEL
Minimum compression level for zstd.