48 # pragma warning(disable : 4127)
61 # define LZ4F_HEAPMODE 0
74 #ifndef LZ4_SRC_INCLUDED
76 # define ALLOC(s) malloc(s)
77 # define ALLOC_AND_ZERO(s) calloc(1,(s))
78 # define FREEMEM(p) free(p)
82 #ifndef LZ4_SRC_INCLUDED
83 # define MEM_INIT(p,v,s) memset((p),(v),(s))
90 #define LZ4F_STATIC_LINKING_ONLY
92 #define LZ4_STATIC_LINKING_ONLY
94 #define LZ4_HC_STATIC_LINKING_ONLY
96 #define XXH_STATIC_LINKING_ONLY
103 #if defined(LZ4_DEBUG) && (LZ4_DEBUG>=1)
107 # define assert(condition) ((void)0)
111 #define LZ4F_STATIC_ASSERT(c) { enum { LZ4F_static_assert = 1/(int)(!!(c)) }; }
113 #if defined(LZ4_DEBUG) && (LZ4_DEBUG>=2) && !defined(DEBUGLOG)
115 static int g_debuglog_enable = 1;
116 # define DEBUGLOG(l, ...) { \
117 if ((g_debuglog_enable) && (l<=LZ4_DEBUG)) { \
118 fprintf(stderr, __FILE__ ": "); \
119 fprintf(stderr, __VA_ARGS__); \
120 fprintf(stderr, " \n"); \
123 # define DEBUGLOG(l, ...) {}
130 #if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) ) )
139 typedef unsigned short U16;
142 typedef unsigned long long U64;
150 U32 value32 = srcPtr[0];
151 value32 += ((
U32)srcPtr[1])<< 8;
152 value32 += ((
U32)srcPtr[2])<<16;
153 value32 += ((
U32)srcPtr[3])<<24;
160 dstPtr[0] = (
BYTE)value32;
161 dstPtr[1] = (
BYTE)(value32 >> 8);
162 dstPtr[2] = (
BYTE)(value32 >> 16);
163 dstPtr[3] = (
BYTE)(value32 >> 24);
169 U64 value64 = srcPtr[0];
170 value64 += ((
U64)srcPtr[1]<<8);
171 value64 += ((
U64)srcPtr[2]<<16);
172 value64 += ((
U64)srcPtr[3]<<24);
173 value64 += ((
U64)srcPtr[4]<<32);
174 value64 += ((
U64)srcPtr[5]<<40);
175 value64 += ((
U64)srcPtr[6]<<48);
176 value64 += ((
U64)srcPtr[7]<<56);
183 dstPtr[0] = (
BYTE)value64;
184 dstPtr[1] = (
BYTE)(value64 >> 8);
185 dstPtr[2] = (
BYTE)(value64 >> 16);
186 dstPtr[3] = (
BYTE)(value64 >> 24);
187 dstPtr[4] = (
BYTE)(value64 >> 32);
188 dstPtr[5] = (
BYTE)(value64 >> 40);
189 dstPtr[6] = (
BYTE)(value64 >> 48);
190 dstPtr[7] = (
BYTE)(value64 >> 56);
197 #ifndef LZ4_SRC_INCLUDED
209 #define LZ4F_MAGIC_SKIPPABLE_START 0x184D2A50U
210 #define LZ4F_MAGICNUMBER 0x184D2204U
211 #define LZ4F_BLOCKUNCOMPRESSED_FLAG 0x80000000U
212 #define LZ4F_BLOCKSIZEID_DEFAULT LZ4F_max64KB
245 #define LZ4F_GENERATE_STRING(STRING) #STRING,
256 static const char* codeError =
"Unspecified error code";
263 if (!
LZ4F_isError(functionResult))
return LZ4F_OK_NoError;
264 return (LZ4F_errorCodes)(-(
ptrdiff_t)functionResult);
280 static const size_t blockSizes[4] = { 64
KB, 256
KB, 1
MB, 4
MB };
283 if (blockSizeID < LZ4F_max64KB || blockSizeID >
LZ4F_max4MB)
284 return err0r(LZ4F_ERROR_maxBlockSize_invalid);
286 return blockSizes[blockSizeID];
292 #define MIN(a,b) ( (a) < (b) ? (a) : (b) )
297 return (
BYTE)(xxh >> 8);
308 size_t maxBlockSize = 64
KB;
309 while (requestedBSID > proposedBSID) {
315 return requestedBSID;
326 size_t alreadyBuffered)
335 size_t const maxBuffered = blockSize - 1;
336 size_t const bufferedSize =
MIN(alreadyBuffered, maxBuffered);
337 size_t const maxSrcSize =
srcSize + bufferedSize;
338 unsigned const nbFullBlocks = (
unsigned)(maxSrcSize / blockSize);
339 size_t const partialBlockSize = maxSrcSize & (blockSize-1);
340 size_t const lastBlockSize = flush ? partialBlockSize : 0;
341 unsigned const nbBlocks = nbFullBlocks + (lastBlockSize>0);
346 return ((
BHSize + blockCRCSize) * nbBlocks) +
347 (blockSize * nbFullBlocks) + lastBlockSize + frameEnd;
356 if (preferencesPtr!=
NULL) prefs = *preferencesPtr;
357 else MEM_INIT(&prefs, 0,
sizeof(prefs));
374 void* dstBuffer,
size_t dstCapacity,
375 const void* srcBuffer,
size_t srcSize,
376 const LZ4F_CDict* cdict,
381 BYTE*
const dstStart = (
BYTE*) dstBuffer;
382 BYTE* dstPtr = dstStart;
383 BYTE*
const dstEnd = dstStart + dstCapacity;
385 if (preferencesPtr!=
NULL)
386 prefs = *preferencesPtr;
401 return err0r(LZ4F_ERROR_dstMaxSize_tooSmall);
405 dstPtr += headerSize; }
415 dstPtr += tailSize; }
417 assert(dstEnd >= dstStart);
418 return (
size_t)(dstPtr - dstStart);
430 const void* srcBuffer,
size_t srcSize,
447 if (preferencesPtr ==
NULL ||
459 NULL, preferencesPtr);
464 if (preferencesPtr !=
NULL &&
492 const char* dictStart = (
const char*)dictBuffer;
493 LZ4F_CDict* cdict = (LZ4F_CDict*)
ALLOC(
sizeof(*cdict));
495 if (!cdict)
return NULL;
496 if (dictSize > 64
KB) {
497 dictStart += dictSize - 64
KB;
500 cdict->dictContent =
ALLOC(dictSize);
503 if (!cdict->dictContent || !cdict->fastCtx || !cdict->HCCtx) {
507 memcpy(cdict->dictContent, dictStart, dictSize);
508 LZ4_loadDict (cdict->fastCtx, (
const char*)cdict->dictContent, (
int)dictSize);
510 LZ4_loadDictHC(cdict->HCCtx, (
const char*)cdict->dictContent, (
int)dictSize);
516 if (cdict==
NULL)
return;
539 if (cctxPtr==
NULL)
return err0r(LZ4F_ERROR_allocation_failed);
544 *LZ4F_compressionContextPtr = cctxPtr;
546 return LZ4F_OK_NoError;
552 if (cctxPtr !=
NULL) {
558 return LZ4F_OK_NoError;
571 const LZ4F_CDict* cdict,
599 void* dstBuffer,
size_t dstCapacity,
600 const LZ4F_CDict* cdict,
604 BYTE*
const dstStart = (
BYTE*)dstBuffer;
605 BYTE* dstPtr = dstStart;
608 if (dstCapacity <
maxFHSize)
return err0r(LZ4F_ERROR_dstMaxSize_tooSmall);
609 MEM_INIT(&prefNull, 0,
sizeof(prefNull));
610 if (preferencesPtr ==
NULL) preferencesPtr = &prefNull;
611 cctxPtr->
prefs = *preferencesPtr;
623 return err0r(LZ4F_ERROR_allocation_failed);
644 {
size_t const requiredBuffSize = preferencesPtr->
autoFlush ?
660 cctxPtr->
cdict = cdict;
672 headerStart = dstPtr;
699 return (
size_t)(dstPtr - dstStart);
711 void* dstBuffer,
size_t dstCapacity,
715 NULL, preferencesPtr);
726 if (preferencesPtr && preferencesPtr->
autoFlush) {
743 const LZ4F_CDict* cdict,
751 DEBUGLOG(5,
"LZ4F_makeBlock: compression failed, creating a raw block (size %u)", (
U32)
srcSize);
768 int const acceleration = (
level < 0) ? -
level + 1 : 1;
779 int const acceleration = (
level < 0) ? -
level + 1 : 1;
795 (void)
level; (void)cdict;
826 void* dstBuffer,
size_t dstCapacity,
827 const void* srcBuffer,
size_t srcSize,
832 const BYTE* srcPtr = (
const BYTE*)srcBuffer;
834 BYTE*
const dstStart = (
BYTE*)dstBuffer;
835 BYTE* dstPtr = dstStart;
841 if (cctxPtr->
cStage != 1)
return err0r(LZ4F_ERROR_GENERIC);
843 return err0r(LZ4F_ERROR_dstMaxSize_tooSmall);
844 MEM_INIT(&cOptionsNull, 0,
sizeof(cOptionsNull));
845 if (compressOptionsPtr ==
NULL) compressOptionsPtr = &cOptionsNull;
849 size_t const sizeToCopy = blockSize - cctxPtr->
tmpInSize;
860 srcPtr += sizeToCopy;
863 cctxPtr->
tmpIn, blockSize,
873 while ((
size_t)(srcEnd - srcPtr) >= blockSize) {
888 srcPtr, (
size_t)(srcEnd - srcPtr),
901 if (realDictSize==0)
return err0r(LZ4F_ERROR_GENERIC);
915 if (srcPtr < srcEnd) {
917 size_t const sizeToCopy = (
size_t)(srcEnd - srcPtr);
926 return (
size_t)(dstPtr - dstStart);
939 void* dstBuffer,
size_t dstCapacity,
942 BYTE*
const dstStart = (
BYTE*)dstBuffer;
943 BYTE* dstPtr = dstStart;
947 if (cctxPtr->
cStage != 1)
return err0r(LZ4F_ERROR_GENERIC);
949 return err0r(LZ4F_ERROR_dstMaxSize_tooSmall);
950 (void)compressOptionsPtr;
961 assert(((
void)
"flush overflows dstBuffer!", (
size_t)(dstPtr - dstStart) <= dstCapacity));
973 return (
size_t)(dstPtr - dstStart);
987 void* dstBuffer,
size_t dstCapacity,
990 BYTE*
const dstStart = (
BYTE*)dstBuffer;
991 BYTE* dstPtr = dstStart;
993 size_t const flushSize =
LZ4F_flush(cctxPtr, dstBuffer, dstCapacity, compressOptionsPtr);
994 DEBUGLOG(5,
"LZ4F_compressEnd: dstCapacity=%u", (
unsigned)dstCapacity);
998 assert(flushSize <= dstCapacity);
999 dstCapacity -= flushSize;
1001 if (dstCapacity < 4)
return err0r(LZ4F_ERROR_dstMaxSize_tooSmall);
1007 if (dstCapacity < 8)
return err0r(LZ4F_ERROR_dstMaxSize_tooSmall);
1008 DEBUGLOG(5,
"Writing 32-bit content checksum");
1018 return err0r(LZ4F_ERROR_frameSize_wrong);
1021 return (
size_t)(dstPtr - dstStart);
1073 *LZ4F_decompressionContextPtr =
NULL;
1074 return err0r(LZ4F_ERROR_allocation_failed);
1077 dctx->
version = versionNumber;
1078 *LZ4F_decompressionContextPtr = dctx;
1079 return LZ4F_OK_NoError;
1115 unsigned blockMode, blockChecksumFlag, contentSizeFlag, contentChecksumFlag, dictIDFlag, blockSizeID;
1116 size_t frameHeaderSize;
1139 #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
1141 DEBUGLOG(4,
"frame header error : unknown magic number");
1142 return err0r(LZ4F_ERROR_frameType_unknown);
1148 {
U32 const FLG = srcPtr[4];
1150 blockChecksumFlag = (
FLG>>4) &
_1BIT;
1152 contentSizeFlag = (
FLG>>3) &
_1BIT;
1153 contentChecksumFlag = (
FLG>>2) &
_1BIT;
1156 if (((
FLG>>1)&
_1BIT) != 0)
return err0r(LZ4F_ERROR_reservedFlag_set);
1157 if (
version != 1)
return err0r(LZ4F_ERROR_headerVersion_wrong);
1161 frameHeaderSize =
minFHSize + (contentSizeFlag?8:0) + (dictIDFlag?4:0);
1163 if (
srcSize < frameHeaderSize) {
1165 if (srcPtr != dctx->
header)
1173 {
U32 const BD = srcPtr[5];
1176 if (((
BD>>7)&
_1BIT) != 0)
return err0r(LZ4F_ERROR_reservedFlag_set);
1177 if (blockSizeID < 4)
return err0r(LZ4F_ERROR_maxBlockSize_invalid);
1178 if (((
BD>>0)&
_4BITS) != 0)
return err0r(LZ4F_ERROR_reservedFlag_set);
1182 assert(frameHeaderSize > 5);
1183 #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
1185 if (HC != srcPtr[frameHeaderSize-1])
1186 return err0r(LZ4F_ERROR_headerChecksum_invalid);
1196 if (contentSizeFlag)
1204 return frameHeaderSize;
1214 if (
src ==
NULL)
return err0r(LZ4F_ERROR_srcPtr_wrong);
1218 return err0r(LZ4F_ERROR_frameHeader_incomplete);
1225 #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
1227 return err0r(LZ4F_ERROR_frameType_unknown);
1234 return minFHSize + (contentSizeFlag?8:0) + (dictIDFlag?4:0);
1255 const void* srcBuffer,
size_t* srcSizePtr)
1269 return err0r(LZ4F_ERROR_frameDecoding_alreadyStarted);
1272 if (
LZ4F_isError(hSize)) { *srcSizePtr=0;
return hSize; }
1273 if (*srcSizePtr < hSize) {
1275 return err0r(LZ4F_ERROR_frameHeader_incomplete);
1282 *srcSizePtr = decodeResult;
1286 return decodeResult;
1296 const BYTE* dstPtr,
size_t dstSize,
const BYTE* dstBufferStart,
1310 assert(dstPtr >= dstBufferStart);
1311 if ((
size_t)(dstPtr - dstBufferStart) + dstSize >= 64
KB) {
1312 dctx->
dict = (
const BYTE*)dstBufferStart;
1334 if (copySize > preserveSize) copySize = preserveSize;
1336 memcpy(dctx->
tmpOutBuffer + preserveSize - copySize, oldDictEnd - copySize, copySize);
1345 size_t const preserveSize = 64
KB - dstSize;
1355 {
size_t preserveSize = 64
KB - dstSize;
1360 dctx->
dictSize = preserveSize + dstSize;
1385 void* dstBuffer,
size_t* dstSizePtr,
1386 const void* srcBuffer,
size_t* srcSizePtr,
1390 const BYTE*
const srcStart = (
const BYTE*)srcBuffer;
1391 const BYTE*
const srcEnd = srcStart + *srcSizePtr;
1392 const BYTE* srcPtr = srcStart;
1393 BYTE*
const dstStart = (
BYTE*)dstBuffer;
1394 BYTE*
const dstEnd = dstStart ? dstStart + *dstSizePtr :
NULL;
1395 BYTE* dstPtr = dstStart;
1397 unsigned doAnotherStage = 1;
1398 size_t nextSrcSizeHint = 1;
1401 DEBUGLOG(5,
"LZ4F_decompress : %p,%u => %p,%u",
1402 srcBuffer, (
unsigned)*srcSizePtr, dstBuffer, (
unsigned)*dstSizePtr);
1403 if (dstBuffer ==
NULL)
assert(*dstSizePtr == 0);
1404 MEM_INIT(&optionsNull, 0,
sizeof(optionsNull));
1405 if (decompressOptionsPtr==
NULL) decompressOptionsPtr = &optionsNull;
1412 while (doAnotherStage) {
1418 DEBUGLOG(6,
"dstage_getFrameHeader");
1419 if ((
size_t)(srcEnd-srcPtr) >=
maxFHSize) {
1426 if (srcEnd-srcPtr == 0)
return minFHSize;
1432 DEBUGLOG(6,
"dstage_storeFrameHeader");
1436 srcPtr += sizeToCopy;
1459 return err0r(LZ4F_ERROR_allocation_failed);
1463 return err0r(LZ4F_ERROR_allocation_failed);
1476 if ((
size_t)(srcEnd - srcPtr) >=
BHSize) {
1477 selectedIn = srcPtr;
1487 {
size_t const remainingInput = (
size_t)(srcEnd - srcPtr);
1489 size_t const sizeToCopy =
MIN(wantedData, remainingInput);
1491 srcPtr += sizeToCopy;
1499 selectedIn = dctx->
tmpIn;
1504 size_t const nextCBlockSize = blockHeader & 0x7FFFFFFFU;
1506 if (blockHeader==0) {
1512 return err0r(LZ4F_ERROR_maxBlockSize_invalid);
1517 DEBUGLOG(5,
"next block is uncompressed (size %u)", (
U32)nextCBlockSize);
1527 if (dstPtr==dstEnd || srcPtr==srcEnd) {
1528 nextSrcSizeHint =
BHSize + nextCBlockSize + crcSize;
1536 {
size_t sizeToCopy;
1537 if (dstPtr ==
NULL) {
1540 size_t const minBuffSize =
MIN((
size_t)(srcEnd-srcPtr), (
size_t)(dstEnd-dstPtr));
1542 memcpy(dstPtr, srcPtr, sizeToCopy);
1556 srcPtr += sizeToCopy;
1557 dstPtr += sizeToCopy;
1576 DEBUGLOG(6,
"dstage_getBlockChecksum");
1577 {
const void* crcSrc;
1578 if ((srcEnd-srcPtr >= 4) && (dctx->
tmpInSize==0)) {
1582 size_t const stillToCopy = 4 - dctx->
tmpInSize;
1583 size_t const sizeToCopy =
MIN(stillToCopy, (
size_t)(srcEnd-srcPtr));
1586 srcPtr += sizeToCopy;
1595 #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
1596 DEBUGLOG(6,
"compare block checksum");
1597 if (readCRC != calcCRC) {
1598 DEBUGLOG(4,
"incorrect block checksum: %08X != %08X",
1600 return err0r(LZ4F_ERROR_blockChecksum_invalid);
1612 if ((
size_t)(srcEnd-srcPtr) < dctx->
tmpInTarget) {
1618 selectedIn = srcPtr;
1624 size_t const inputLeft = (
size_t)(srcEnd-srcPtr);
1625 size_t const sizeToCopy =
MIN(wantedData, inputLeft);
1628 srcPtr += sizeToCopy;
1636 selectedIn = dctx->
tmpIn;
1645 #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
1646 if (readBlockCrc != calcBlockCrc)
1647 return err0r(LZ4F_ERROR_blockChecksum_invalid);
1655 const char* dict = (
const char*)dctx->
dict;
1659 if (dict && dictSize > 1
GB) {
1661 dict += dictSize - 64
KB;
1666 (
const char*)selectedIn, (
char*)dstPtr,
1668 dict, (
int)dictSize);
1669 if (decodedSize < 0)
return err0r(LZ4F_ERROR_GENERIC);
1680 dstPtr += decodedSize;
1695 size_t const reservedDictSpace =
MIN(dctx->
dictSize, 64
KB);
1700 {
const char* dict = (
const char*)dctx->
dict;
1703 if (dict && dictSize > 1
GB) {
1705 dict += dictSize - 64
KB;
1709 (
const char*)selectedIn, (
char*)dctx->
tmpOut,
1711 dict, (
int)dictSize);
1712 if (decodedSize < 0)
1713 return err0r(LZ4F_ERROR_decompressionFailed);
1726 if (dstPtr !=
NULL) {
1735 dstPtr += sizeToCopy;
1743 nextSrcSizeHint =
BHSize;
1748 return err0r(LZ4F_ERROR_frameSize_wrong);
1750 nextSrcSizeHint = 0;
1755 if ((srcEnd - srcPtr) < 4) {
1759 selectedIn = srcPtr;
1765 {
size_t const remainingInput = (
size_t)(srcEnd - srcPtr);
1766 size_t const wantedData = 4 - dctx->
tmpInSize;
1767 size_t const sizeToCopy =
MIN(wantedData, remainingInput);
1769 srcPtr += sizeToCopy;
1776 selectedIn = dctx->
tmpIn;
1782 #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
1783 if (readCRC != resultCRC)
1784 return err0r(LZ4F_ERROR_contentChecksum_invalid);
1789 nextSrcSizeHint = 0;
1796 if ((srcEnd - srcPtr) >= 4) {
1797 selectedIn = srcPtr;
1809 (
size_t)(srcEnd - srcPtr) );
1811 srcPtr += sizeToCopy;
1819 selectedIn = dctx->
header + 4;
1831 {
size_t const skipSize =
MIN(dctx->
tmpInTarget, (
size_t)(srcEnd-srcPtr));
1836 if (nextSrcSizeHint)
break;
1857 if (copySize > preserveSize) copySize = preserveSize;
1860 memcpy(dctx->
tmpOutBuffer + preserveSize - copySize, oldDictEnd - copySize, copySize);
1876 *srcSizePtr = (
size_t)(srcPtr - srcStart);
1877 *dstSizePtr = (
size_t)(dstPtr - dstStart);
1878 return nextSrcSizeHint;
1887 void* dstBuffer,
size_t* dstSizePtr,
1888 const void* srcBuffer,
size_t* srcSizePtr,
1889 const void* dict,
size_t dictSize,
1897 srcBuffer, srcSizePtr,
1898 decompressOptionsPtr);
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static const char struct stat static buf struct stat static buf static vhangup int options
static void struct sockaddr socklen_t static fromlen static backlog static fork char char char static envp int struct rusage static rusage struct utsname static buf struct sembuf unsigned
XXH_PUBLIC_API unsigned int XXH32_digest(const XXH32_state_t *state_in)
XXH_PUBLIC_API unsigned int XXH32(const void *input, size_t len, unsigned int seed)
XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t *statePtr, unsigned int seed)
XXH_PUBLIC_API XXH_errorcode XXH32_update(XXH32_state_t *state_in, const void *input, size_t len)
struct XXH32_state_s XXH32_state_t
int LZ4_loadDict(LZ4_stream_t *LZ4_dict, const char *dictionary, int dictSize)
LZ4_stream_t * LZ4_createStream(void)
int LZ4_decompress_safe_usingDict(const char *source, char *dest, int compressedSize, int maxOutputSize, const char *dictStart, int dictSize)
LZ4_stream_t * LZ4_initStream(void *buffer, size_t size)
void LZ4_resetStream_fast(LZ4_stream_t *ctx)
int LZ4_freeStream(LZ4_stream_t *LZ4_stream)
int LZ4_saveDict(LZ4_stream_t *LZ4_dict, char *safeBuffer, int dictSize)
int LZ4_compress_fast_continue(LZ4_stream_t *LZ4_stream, const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
int LZ4_compress_fast_extState_fastReset(void *state, const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
void LZ4_attach_dictionary(LZ4_stream_t *workingStream, const LZ4_stream_t *dictionaryStream)
LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx *dctx)
struct LZ4F_cctx_s LZ4F_cctx_t
static size_t LZ4F_makeBlock(void *dst, const void *src, size_t srcSize, compressFunc_t compress, void *lz4ctx, int level, const LZ4F_CDict *cdict, LZ4F_blockChecksum_t crcFlag)
static void LZ4F_writeLE32(void *dst, U32 value32)
static LZ4F_blockSizeID_t LZ4F_optimalBSID(const LZ4F_blockSizeID_t requestedBSID, const size_t srcSize)
size_t LZ4F_compressBegin(LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const LZ4F_preferences_t *preferencesPtr)
static size_t LZ4F_compressBound_internal(size_t srcSize, const LZ4F_preferences_t *preferencesPtr, size_t alreadyBuffered)
size_t LZ4F_getBlockSize(unsigned blockSizeID)
size_t LZ4F_compressUpdate(LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_compressOptions_t *compressOptionsPtr)
@ dstage_getBlockChecksum
@ dstage_storeBlockHeader
@ dstage_storeFrameHeader
int LZ4F_compressionLevel_max(void)
static U32 LZ4F_readLE32(const void *src)
LZ4F_CDict * LZ4F_createCDict(const void *dictBuffer, size_t dictSize)
static void LZ4F_updateDict(LZ4F_dctx *dctx, const BYTE *dstPtr, size_t dstSize, const BYTE *dstBufferStart, unsigned withinTmp)
size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
size_t LZ4F_flush(LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t *compressOptionsPtr)
static const size_t minFHSize
size_t LZ4F_compressFrame_usingCDict(LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_CDict *cdict, const LZ4F_preferences_t *preferencesPtr)
size_t LZ4F_decompress_usingDict(LZ4F_dctx *dctx, void *dstBuffer, size_t *dstSizePtr, const void *srcBuffer, size_t *srcSizePtr, const void *dict, size_t dictSize, const LZ4F_decompressOptions_t *decompressOptionsPtr)
static int LZ4F_compressBlockHC(void *ctx, const char *src, char *dst, int srcSize, int dstCapacity, int level, const LZ4F_CDict *cdict)
static int LZ4F_compressBlock(void *ctx, const char *src, char *dst, int srcSize, int dstCapacity, int level, const LZ4F_CDict *cdict)
static const size_t BHSize
size_t LZ4F_decompress(LZ4F_dctx *dctx, void *dstBuffer, size_t *dstSizePtr, const void *srcBuffer, size_t *srcSizePtr, const LZ4F_decompressOptions_t *decompressOptionsPtr)
static const size_t maxFHSize
#define LZ4F_MAGIC_SKIPPABLE_START
#define LZ4F_BLOCKUNCOMPRESSED_FLAG
static int LZ4F_compressBlockHC_continue(void *ctx, const char *src, char *dst, int srcSize, int dstCapacity, int level, const LZ4F_CDict *cdict)
static compressFunc_t LZ4F_selectCompression(LZ4F_blockMode_t blockMode, int level)
size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
static const char * LZ4F_errorStrings[]
static size_t LZ4F_decodeHeader(LZ4F_dctx *dctx, const void *src, size_t srcSize)
LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_cctx *cctxPtr)
static LZ4F_errorCode_t err0r(LZ4F_errorCodes code)
#define LZ4F_BLOCKSIZEID_DEFAULT
unsigned LZ4F_getVersion(void)
unsigned LZ4F_isError(LZ4F_errorCode_t code)
LZ4F_errorCode_t LZ4F_getFrameInfo(LZ4F_dctx *dctx, LZ4F_frameInfo_t *frameInfoPtr, const void *srcBuffer, size_t *srcSizePtr)
LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_dctx **LZ4F_decompressionContextPtr, unsigned versionNumber)
#define ALLOC_AND_ZERO(s)
#define MEM_INIT(p, v, s)
static int LZ4F_compressBlock_continue(void *ctx, const char *src, char *dst, int srcSize, int dstCapacity, int level, const LZ4F_CDict *cdict)
void LZ4F_resetDecompressionContext(LZ4F_dctx *dctx)
size_t LZ4F_compressFrame(void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
LZ4F_errorCode_t LZ4F_createCompressionContext(LZ4F_cctx **LZ4F_compressionContextPtr, unsigned version)
static U64 LZ4F_readLE64(const void *src)
static void LZ4F_writeLE64(void *dst, U64 value64)
static int LZ4F_localSaveDict(LZ4F_cctx_t *cctxPtr)
#define assert(condition)
static BYTE LZ4F_headerChecksum(const void *header, size_t length)
LZ4F_errorCodes LZ4F_getErrorCode(size_t functionResult)
void LZ4F_freeCDict(LZ4F_CDict *cdict)
const char * LZ4F_getErrorName(LZ4F_errorCode_t code)
#define LZ4F_STATIC_ASSERT(c)
size_t LZ4F_compressEnd(LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t *compressOptionsPtr)
static void LZ4F_initStream(void *ctx, const LZ4F_CDict *cdict, int level, LZ4F_blockMode_t blockMode)
static const size_t BFSize
size_t LZ4F_headerSize(const void *src, size_t srcSize)
size_t LZ4F_compressBegin_usingCDict(LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const LZ4F_CDict *cdict, const LZ4F_preferences_t *preferencesPtr)
#define LZ4F_GENERATE_STRING(STRING)
int(* compressFunc_t)(void *ctx, const char *src, char *dst, int srcSize, int dstSize, int level, const LZ4F_CDict *cdict)
#define LZ4F_MIN_SIZE_TO_KNOW_HEADER_LENGTH
#define LZ4F_HEADER_SIZE_MAX
#define LZ4F_BLOCK_HEADER_SIZE
#define LZ4F_HEADER_SIZE_MIN
#define LZ4F_INIT_PREFERENCES
#define LZ4F_BLOCK_CHECKSUM_SIZE
@ LZ4F_contentChecksumEnabled
@ LZ4F_blockChecksumEnabled
void LZ4_favorDecompressionSpeed(LZ4_streamHC_t *LZ4_streamHCPtr, int favor)
void LZ4_attach_HC_dictionary(LZ4_streamHC_t *working_stream, const LZ4_streamHC_t *dictionary_stream)
void LZ4_resetStreamHC_fast(LZ4_streamHC_t *LZ4_streamHCPtr, int compressionLevel)
int LZ4_saveDictHC(LZ4_streamHC_t *LZ4_streamHCPtr, char *safeBuffer, int dictSize)
LZ4_streamHC_t * LZ4_initStreamHC(void *buffer, size_t size)
int LZ4_freeStreamHC(LZ4_streamHC_t *LZ4_streamHCPtr)
int LZ4_compress_HC_continue(LZ4_streamHC_t *LZ4_streamHCPtr, const char *src, char *dst, int srcSize, int dstCapacity)
LZ4_streamHC_t * LZ4_createStreamHC(void)
int LZ4_compress_HC_extStateHC_fastReset(void *state, const char *src, char *dst, int srcSize, int dstCapacity, int compressionLevel)
void LZ4_setCompressionLevel(LZ4_streamHC_t *LZ4_streamHCPtr, int compressionLevel)
int LZ4_loadDictHC(LZ4_streamHC_t *LZ4_streamHCPtr, const char *dictionary, int dictSize)
#define LZ4HC_CLEVEL_DEFAULT
#define header(is_bt, len_min, ret_op)
XXH32_state_t blockChecksum
BYTE header[LZ4F_HEADER_SIZE_MAX]
LZ4F_frameInfo_t frameInfo
LZ4F_contentChecksum_t contentChecksumFlag
unsigned long long contentSize
LZ4F_frameType_t frameType
LZ4F_blockChecksum_t blockChecksumFlag
LZ4F_blockMode_t blockMode
LZ4F_blockSizeID_t blockSizeID
LZ4F_frameInfo_t frameInfo
if(dbg->bits==RZ_SYS_BITS_64)
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)