MCPcopy Create free account
hub / github.com/F-Stack/f-stack / compress_orDie

Function compress_orDie

freebsd/contrib/zstd/examples/simple_compression.c:17–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include "common.h" // Helper functions, CHECK(), and CHECK_ZSTD()
16
17static void compress_orDie(const char* fname, const char* oname)
18{
19 size_t fSize;
20 void* const fBuff = mallocAndLoadFile_orDie(fname, &fSize);
21 size_t const cBuffSize = ZSTD_compressBound(fSize);
22 void* const cBuff = malloc_orDie(cBuffSize);
23
24 /* Compress.
25 * If you are doing many compressions, you may want to reuse the context.
26 * See the multiple_simple_compression.c example.
27 */
28 size_t const cSize = ZSTD_compress(cBuff, cBuffSize, fBuff, fSize, 1);
29 CHECK_ZSTD(cSize);
30
31 saveFile_orDie(oname, cBuff, cSize);
32
33 /* success */
34 printf("%25s : %6u -> %7u - %s \n", fname, (unsigned)fSize, (unsigned)cSize, oname);
35
36 free(fBuff);
37 free(cBuff);
38}
39
40static char* createOutFilename_orDie(const char* filename)
41{

Callers 1

mainFunction · 0.85

Calls 7

mallocAndLoadFile_orDieFunction · 0.85
malloc_orDieFunction · 0.85
saveFile_orDieFunction · 0.85
ZSTD_compressBoundFunction · 0.50
ZSTD_compressFunction · 0.50
printfFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected