NeoMutt  2024-11-14-34-g5aaf0d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches

Open a compression context. More...

+ Collaboration diagram for open():

Functions

static ComprHandlecompr_lz4_open (short level)
 Open a compression context - Implements ComprOps::open() -.
 
static ComprHandlecompr_zlib_open (short level)
 Open a compression context - Implements ComprOps::open() -.
 
static ComprHandlecompr_zstd_open (short level)
 Open a compression context - Implements ComprOps::open() -.
 

Detailed Description

Open a compression context.

Parameters
[in]levelThe compression level
Return values
ptrSuccess, Compression private data
NULLOtherwise

Function Documentation

◆ compr_lz4_open()

static ComprHandle * compr_lz4_open ( short  level)
static

Open a compression context - Implements ComprOps::open() -.

Definition at line 79 of file lz4.c.

80{
81 struct Lz4ComprData *cdata = lz4_cdata_new();
82
83 cdata->buf = mutt_mem_calloc(LZ4_compressBound(1024 * 32), 1);
84
86 {
87 mutt_debug(LL_DEBUG1, "The compression level for %s should be between %d and %d",
90 }
91
92 cdata->level = level;
93
94 // Return an opaque pointer
95 return (ComprHandle *) cdata;
96}
void ComprHandle
Opaque type for compression data.
Definition: lib.h:56
const struct ComprOps compr_lz4_ops
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
#define MAX_COMP_LEVEL
Maximum compression level for lz4.
Definition: lz4.c:41
#define MIN_COMP_LEVEL
Minimum compression level for lz4.
Definition: lz4.c:40
static struct Lz4ComprData * lz4_cdata_new(void)
Create new Lz4 Compression Data.
Definition: lz4.c:71
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:77
const char * name
Compression name.
Definition: lib.h:65
Private Lz4 Compression Data.
Definition: lz4.c:47
void * buf
Temporary buffer.
Definition: lz4.c:48
short level
Compression Level to be used.
Definition: lz4.c:49
+ Here is the call graph for this function:

◆ compr_zlib_open()

static ComprHandle * compr_zlib_open ( short  level)
static

Open a compression context - Implements ComprOps::open() -.

Definition at line 79 of file zlib.c.

80{
81 struct ZlibComprData *cdata = zlib_cdata_new();
82
83 cdata->buf = mutt_mem_calloc(compressBound(1024 * 32), 1);
84
86 {
87 mutt_debug(LL_DEBUG1, "The compression level for %s should be between %d and %d",
90 }
91
92 cdata->level = level;
93
94 // Return an opaque pointer
95 return (ComprHandle *) cdata;
96}
const struct ComprOps compr_zlib_ops
Private Zlib Compression Data.
Definition: zlib.c:47
short level
Compression Level to be used.
Definition: zlib.c:49
void * buf
Temporary buffer.
Definition: zlib.c:48
static struct ZlibComprData * zlib_cdata_new(void)
Create new Zlib Compression Data.
Definition: zlib.c:71
#define MAX_COMP_LEVEL
Maximum compression level for zlib.
Definition: zlib.c:41
#define MIN_COMP_LEVEL
Minimum compression level for zlib.
Definition: zlib.c:40
+ Here is the call graph for this function:

◆ compr_zstd_open()

static ComprHandle * compr_zstd_open ( short  level)
static

Open a compression context - Implements ComprOps::open() -.

Definition at line 81 of file zstd.c.

82{
83 struct ZstdComprData *cdata = zstd_cdata_new();
84
85 cdata->buf = mutt_mem_calloc(ZSTD_compressBound(1024 * 128), 1);
86 cdata->cctx = ZSTD_createCCtx();
87 cdata->dctx = ZSTD_createDCtx();
88
89 if (!cdata->cctx || !cdata->dctx)
90 {
91 // LCOV_EXCL_START
92 ZSTD_freeCCtx(cdata->cctx);
93 ZSTD_freeDCtx(cdata->dctx);
94 zstd_cdata_free(&cdata);
95 return NULL;
96 // LCOV_EXCL_STOP
97 }
98
100 {
101 mutt_debug(LL_DEBUG1, "The compression level for %s should be between %d and %d",
104 }
105
106 cdata->level = level;
107
108 // Return an opaque pointer
109 return (ComprHandle *) cdata;
110}
const struct ComprOps compr_zstd_ops
Private Zstandard Compression Data.
Definition: zstd.c:46
short level
Compression Level to be used.
Definition: zstd.c:48
ZSTD_CCtx * cctx
Compression context.
Definition: zstd.c:50
ZSTD_DCtx * dctx
Decompression context.
Definition: zstd.c:51
void * buf
Temporary buffer.
Definition: zstd.c:47
void zstd_cdata_free(struct ZstdComprData **ptr)
Free Zstandard Compression Data.
Definition: zstd.c:58
static struct ZstdComprData * zstd_cdata_new(void)
Create new Zstandard Compression Data.
Definition: zstd.c:73
#define MAX_COMP_LEVEL
Maximum compression level for zstd.
Definition: zstd.c:40
#define MIN_COMP_LEVEL
Minimum compression level for zstd.
Definition: zstd.c:39
+ Here is the call graph for this function: