Decompress header cache data.
More...
Decompress header cache data.
- Parameters
-
[in] | handle | Compression handle |
[in] | cbuf | Data to be decompressed |
[in] | clen | Length of the compressed input data |
- Return values
-
ptr | Success, pointer to decompressed data |
NULL | Otherwise |
- Note
- This function returns a pointer to data, which will be freed by the close() function.
◆ compr_lz4_decompress()
static void * compr_lz4_decompress |
( |
ComprHandle * |
handle, |
|
|
const char * |
cbuf, |
|
|
size_t |
clen |
|
) |
| |
|
static |
Decompress header cache data - Implements ComprOps::decompress() -.
Definition at line 138 of file lz4.c.
139{
140 if (!handle)
141 return NULL;
142
143
145
146
147 const unsigned char *cs = (const unsigned char *) cbuf;
148 if (clen < 4)
149 return NULL;
150 size_t ulen = cs[0] + (cs[1] << 8) + (cs[2] << 16) + ((size_t) cs[3] << 24);
151 if (ulen > INT_MAX)
152 return NULL;
153 if (ulen == 0)
154 return (void *) cbuf;
155
157 void *ubuf = cdata->
buf;
158 const char *data = cbuf;
159 int rc = LZ4_decompress_safe(data + 4, ubuf, clen - 4, ulen);
160 if (rc < 0)
161 return NULL;
162
163 return ubuf;
164}
void mutt_mem_realloc(void *pptr, size_t size)
Resize a block of memory on the heap.
Private Lz4 Compression Data.
void * buf
Temporary buffer.
◆ compr_zlib_decompress()
static void * compr_zlib_decompress |
( |
ComprHandle * |
handle, |
|
|
const char * |
cbuf, |
|
|
size_t |
clen |
|
) |
| |
|
static |
Decompress header cache data - Implements ComprOps::decompress() -.
Definition at line 135 of file zlib.c.
136{
137 if (!handle)
138 return NULL;
139
140
142
143
144 const unsigned char *cs = (const unsigned char *) cbuf;
145 if (clen < 4)
146 return NULL;
147 uLong ulen = cs[0] + (cs[1] << 8) + (cs[2] << 16) + ((uLong) cs[3] << 24);
148 if (ulen == 0)
149 return NULL;
150
152 Bytef *ubuf = cdata->
buf;
153 cs = (const unsigned char *) cbuf;
154 int rc = uncompress(ubuf, &ulen, cs + 4, clen - 4);
155 if (rc != Z_OK)
156 return NULL;
157
158 return ubuf;
159}
Private Zlib Compression Data.
void * buf
Temporary buffer.
◆ compr_zstd_decompress()
static void * compr_zstd_decompress |
( |
ComprHandle * |
handle, |
|
|
const char * |
cbuf, |
|
|
size_t |
clen |
|
) |
| |
|
static |
Decompress header cache data - Implements ComprOps::decompress() -.
Definition at line 139 of file zstd.c.
140{
141 if (!handle)
142 return NULL;
143
144
146
147 unsigned long long len = ZSTD_getFrameContentSize(cbuf, clen);
148 if (len == ZSTD_CONTENTSIZE_UNKNOWN)
149 return NULL;
150 else if (len == ZSTD_CONTENTSIZE_ERROR)
151 return NULL;
152 else if (len == 0)
153 return NULL;
155
156 size_t rc = ZSTD_decompressDCtx(cdata->
dctx, cdata->
buf, len, cbuf, clen);
157 if (ZSTD_isError(rc))
158 return NULL;
159
161}
Private Zstandard Compression Data.
ZSTD_DCtx * dctx
Decompression context.
void * buf
Temporary buffer.