Merge pull request #588 from khabinov/stream-dirty-followups
Some followups and renamings
This commit is contained in:
commit
637245958f
15
lib/lz4.c
15
lib/lz4.c
@ -613,7 +613,7 @@ LZ4_FORCE_INLINE void LZ4_prepareTable(
|
||||
/* If compression failed during the previous step, then the context
|
||||
* is marked as dirty, therefore, it has to be fully reset.
|
||||
*/
|
||||
if (cctx->dirtyContext) {
|
||||
if (cctx->dirty) {
|
||||
DEBUGLOG(5, "LZ4_prepareTable: Full reset for %p", cctx);
|
||||
MEM_INIT(cctx, 0, sizeof(LZ4_stream_t_internal));
|
||||
return;
|
||||
@ -704,10 +704,11 @@ LZ4_FORCE_INLINE int LZ4_compress_generic(
|
||||
U32 forwardH;
|
||||
|
||||
DEBUGLOG(5, "LZ4_compress_generic: srcSize=%i, tableType=%u", inputSize, tableType);
|
||||
/* Init conditions */
|
||||
if (outputLimited == fillOutput && maxOutputSize < 1) goto _failure; /* Impossible to store anything */
|
||||
if ((U32)inputSize > (U32)LZ4_MAX_INPUT_SIZE) goto _failure; /* Unsupported inputSize, too large (or negative) */
|
||||
if ((tableType == byU16) && (inputSize>=LZ4_64Klimit)) goto _failure; /* Size too large (not within 64K limit) */
|
||||
/* If init conditions are not met, we don't have to mark stream
|
||||
* as having dirty context, since no action was taken yet */
|
||||
if (outputLimited == fillOutput && maxOutputSize < 1) return 0; /* Impossible to store anything */
|
||||
if ((U32)inputSize > (U32)LZ4_MAX_INPUT_SIZE) return 0; /* Unsupported inputSize, too large (or negative) */
|
||||
if ((tableType == byU16) && (inputSize>=LZ4_64Klimit)) return 0; /* Size too large (not within 64K limit) */
|
||||
if (tableType==byPtr) assert(dictDirective==noDict); /* only supported use case with byPtr */
|
||||
assert(acceleration >= 1);
|
||||
|
||||
@ -1021,7 +1022,7 @@ _last_literals:
|
||||
|
||||
_failure:
|
||||
/* Mark stream as having dirty context, so, it has to be fully reset */
|
||||
cctx->dirtyContext = 1;
|
||||
cctx->dirty = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1300,7 +1301,7 @@ int LZ4_compress_fast_continue (LZ4_stream_t* LZ4_stream, const char* source, ch
|
||||
|
||||
DEBUGLOG(5, "LZ4_compress_fast_continue (inputSize=%i)", inputSize);
|
||||
|
||||
if (streamPtr->dirtyContext) return 0; /* Uninitialized structure detected */
|
||||
if (streamPtr->dirty) return 0; /* Uninitialized structure detected */
|
||||
LZ4_renormDictT(streamPtr, inputSize); /* avoid index overflow */
|
||||
if (acceleration < 1) acceleration = ACCELERATION_DEFAULT;
|
||||
|
||||
|
@ -511,7 +511,7 @@ typedef struct LZ4_stream_t_internal LZ4_stream_t_internal;
|
||||
struct LZ4_stream_t_internal {
|
||||
uint32_t hashTable[LZ4_HASH_SIZE_U32];
|
||||
uint32_t currentOffset;
|
||||
uint16_t dirtyContext;
|
||||
uint16_t dirty;
|
||||
uint16_t tableType;
|
||||
const uint8_t* dictionary;
|
||||
const LZ4_stream_t_internal* dictCtx;
|
||||
@ -531,7 +531,7 @@ typedef struct LZ4_stream_t_internal LZ4_stream_t_internal;
|
||||
struct LZ4_stream_t_internal {
|
||||
unsigned int hashTable[LZ4_HASH_SIZE_U32];
|
||||
unsigned int currentOffset;
|
||||
unsigned short dirtyContext;
|
||||
unsigned short dirty;
|
||||
unsigned short tableType;
|
||||
const unsigned char* dictionary;
|
||||
const LZ4_stream_t_internal* dictCtx;
|
||||
|
@ -744,7 +744,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
|
||||
LZ4_attach_dictionary(&LZ4_stream, &LZ4dict);
|
||||
blockContinueCompressedSize = LZ4_compress_fast_continue(&LZ4_stream, block, compressedBuffer, blockSize, (int)compressedBufferSize, 1);
|
||||
FUZ_CHECKTEST(blockContinueCompressedSize==0, "LZ4_compress_fast_continue using extDictCtx failed");
|
||||
FUZ_CHECKTEST(LZ4_stream.internal_donotuse.dirtyContext, "context should be good");
|
||||
FUZ_CHECKTEST(LZ4_stream.internal_donotuse.dirty, "context should be good");
|
||||
|
||||
/* In the future, it might be desirable to let extDictCtx mode's
|
||||
* output diverge from the output generated by regular extDict mode.
|
||||
@ -759,7 +759,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
|
||||
LZ4_attach_dictionary(&LZ4_stream, &LZ4dict);
|
||||
ret = LZ4_compress_fast_continue(&LZ4_stream, block, compressedBuffer, blockSize, blockContinueCompressedSize-1, 1);
|
||||
FUZ_CHECKTEST(ret>0, "LZ4_compress_fast_continue using extDictCtx should fail : one missing byte for output buffer : %i written, %i buffer", ret, blockContinueCompressedSize);
|
||||
FUZ_CHECKTEST(!LZ4_stream.internal_donotuse.dirtyContext, "context should be dirty");
|
||||
FUZ_CHECKTEST(!LZ4_stream.internal_donotuse.dirty, "context should be dirty");
|
||||
|
||||
FUZ_DISPLAYTEST();
|
||||
LZ4_resetStream_fast(&LZ4_stream);
|
||||
@ -769,7 +769,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
|
||||
FUZ_CHECKTEST(ret<=0, "LZ4_compress_fast_continue using extDictCtx should work : enough size available within output buffer");
|
||||
FUZ_CHECKTEST(ret != expectedSize, "LZ4_compress_fast_continue using extDictCtx produced different-sized output");
|
||||
FUZ_CHECKTEST(XXH32(compressedBuffer, ret, 0) != expectedCrc, "LZ4_compress_fast_continue using extDictCtx produced different output");
|
||||
FUZ_CHECKTEST(LZ4_stream.internal_donotuse.dirtyContext, "context should be good");
|
||||
FUZ_CHECKTEST(LZ4_stream.internal_donotuse.dirty, "context should be good");
|
||||
|
||||
FUZ_DISPLAYTEST();
|
||||
LZ4_resetStream_fast(&LZ4_stream);
|
||||
@ -779,7 +779,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
|
||||
FUZ_CHECKTEST(ret<=0, "LZ4_compress_fast_continue using extDictCtx with re-used context should work : enough size available within output buffer");
|
||||
FUZ_CHECKTEST(ret != expectedSize, "LZ4_compress_fast_continue using extDictCtx produced different-sized output");
|
||||
FUZ_CHECKTEST(XXH32(compressedBuffer, ret, 0) != expectedCrc, "LZ4_compress_fast_continue using extDictCtx produced different output");
|
||||
FUZ_CHECKTEST(LZ4_stream.internal_donotuse.dirtyContext, "context should be good");
|
||||
FUZ_CHECKTEST(LZ4_stream.internal_donotuse.dirty, "context should be good");
|
||||
}
|
||||
|
||||
/* Decompress with dictionary as external */
|
||||
@ -994,7 +994,7 @@ static void FUZ_unitTests(int compressionLevel)
|
||||
LZ4_resetStream(&streamingState);
|
||||
result = LZ4_compress_fast_continue(&streamingState, testInput, testCompressed, testCompressedSize, testCompressedSize-1, 1);
|
||||
FUZ_CHECKTEST(result==0, "LZ4_compress_fast_continue() compression failed!");
|
||||
FUZ_CHECKTEST(streamingState.internal_donotuse.dirtyContext, "dirtyContext flag is set")
|
||||
FUZ_CHECKTEST(streamingState.internal_donotuse.dirty, "context should be clean")
|
||||
|
||||
result = LZ4_decompress_safe(testCompressed, testVerify, result, testCompressedSize);
|
||||
FUZ_CHECKTEST(result!=(int)testCompressedSize, "LZ4_decompress_safe() decompression failed");
|
||||
|
Loading…
Reference in New Issue
Block a user