40#define MIN_COMP_LEVEL 1
41#define MAX_COMP_LEVEL 12
102 size_t dlen,
size_t *clen)
104 if (!handle || (dlen > INT_MAX))
111 int len = LZ4_compressBound(dlen);
112 if (len > (INT_MAX - 4))
115 char *cbuf = cdata->
buf;
117 len = LZ4_compress_fast(data, cbuf + 4, datalen, len, cdata->
level);
123 unsigned char *cs = cdata->
buf;
147 const unsigned char *cs = (
const unsigned char *) cbuf;
150 size_t ulen = cs[0] + (cs[1] << 8) + (cs[2] << 16) + ((size_t) cs[3] << 24);
154 return (
void *) cbuf;
157 void *ubuf = cdata->
buf;
158 const char *data = cbuf;
159 int rc = LZ4_decompress_safe(data + 4, ubuf, clen - 4, ulen);
void ComprHandle
Opaque type for compression data.
const struct ComprOps compr_lz4_ops
#define COMPRESS_OPS(_name, _min_level, _max_level)
static void compr_lz4_close(ComprHandle **ptr)
Close a compression context - Implements ComprOps::close() -.
static void * compr_lz4_compress(ComprHandle *handle, const char *data, size_t dlen, size_t *clen)
Compress header cache data - Implements ComprOps::compress() -.
static void * compr_lz4_decompress(ComprHandle *handle, const char *cbuf, size_t clen)
Decompress header cache data - Implements ComprOps::decompress() -.
static ComprHandle * compr_lz4_open(short level)
Open a compression context - Implements ComprOps::open() -.
#define mutt_debug(LEVEL,...)
@ LL_DEBUG1
Log at debug level 1.
void lz4_cdata_free(struct Lz4ComprData **ptr)
Free Lz4 Compression Data.
#define MAX_COMP_LEVEL
Maximum compression level for lz4.
#define MIN_COMP_LEVEL
Minimum compression level for lz4.
static struct Lz4ComprData * lz4_cdata_new(void)
Create new Lz4 Compression Data.
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 Lz4 Compression Data.
void * buf
Temporary buffer.
short level
Compression Level to be used.