changed naming convention to *_usingDict()

This commit is contained in:
Yann Collet 2014-05-04 13:26:05 +01:00
parent 200d87c684
commit 7bcb3b2e9f
4 changed files with 38 additions and 39 deletions

25
lz4.c
View File

@ -888,29 +888,19 @@ int LZ4_decompress_safe(const char* source, char* dest, int compressedSize, int
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, noDict, NULL, 0); return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, noDict, NULL, 0);
} }
int LZ4_decompress_safe_partial(const char* source, char* dest, int compressedSize, int targetOutputSize, int maxOutputSize)
{
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, partial, targetOutputSize, noDict, NULL, 0);
}
int LZ4_decompress_safe_withPrefix64k(const char* source, char* dest, int compressedSize, int maxOutputSize) int LZ4_decompress_safe_withPrefix64k(const char* source, char* dest, int compressedSize, int maxOutputSize)
{ {
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, withPrefix64k, NULL, 0); return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, withPrefix64k, NULL, 0);
} }
int LZ4_decompress_safe_withDict(const char* source, char* dest, int compressedSize, int maxOutputSize, const char* dictStart, int dictSize) int LZ4_decompress_safe_usingDict(const char* source, char* dest, int compressedSize, int maxOutputSize, const char* dictStart, int dictSize)
{ {
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, withExtDict, dictStart, dictSize); return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, withExtDict, dictStart, dictSize);
} }
int LZ4_decompress_fast_withPrefix64k(const char* source, char* dest, int originalSize) int LZ4_decompress_safe_partial(const char* source, char* dest, int compressedSize, int targetOutputSize, int maxOutputSize)
{ {
return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, withPrefix64k, NULL, 0); return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, partial, targetOutputSize, noDict, NULL, 0);
}
int LZ4_decompress_fast_withDict(const char* source, char* dest, int originalSize, const char* dictStart, int dictSize)
{
return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, withExtDict, dictStart, dictSize);
} }
int LZ4_decompress_fast(const char* source, char* dest, int originalSize) int LZ4_decompress_fast(const char* source, char* dest, int originalSize)
@ -922,6 +912,15 @@ int LZ4_decompress_fast(const char* source, char* dest, int originalSize)
#endif #endif
} }
int LZ4_decompress_fast_withPrefix64k(const char* source, char* dest, int originalSize)
{
return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, withPrefix64k, NULL, 0);
}
int LZ4_decompress_fast_usingDict(const char* source, char* dest, int originalSize, const char* dictStart, int dictSize)
{
return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, withExtDict, dictStart, dictSize);
}
/************************************** /**************************************

4
lz4.h
View File

@ -241,8 +241,8 @@ int LZ4_decompress_fast_withPrefix64k (const char* source, char* dest, int origi
but can also use up to 64KB of dictionary data but can also use up to 64KB of dictionary data
to decode chained blocks. to decode chained blocks.
*/ */
int LZ4_decompress_safe_withDict (const char* source, char* dest, int compressedSize, int maxOutputSize, const char* dictStart, int dictSize); int LZ4_decompress_safe_usingDict (const char* source, char* dest, int compressedSize, int maxOutputSize, const char* dictStart, int dictSize);
int LZ4_decompress_fast_withDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize); int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize);

View File

@ -321,17 +321,17 @@ static inline int local_LZ4_decompress_fast_withPrefix64k(const char* in, char*
return outSize; return outSize;
} }
static inline int local_LZ4_decompress_fast_withDict(const char* in, char* out, int inSize, int outSize) static inline int local_LZ4_decompress_fast_usingDict(const char* in, char* out, int inSize, int outSize)
{ {
(void)inSize; (void)inSize;
LZ4_decompress_fast_withDict(in, out, outSize, in - 65536, 65536); LZ4_decompress_fast_usingDict(in, out, outSize, in - 65536, 65536);
return outSize; return outSize;
} }
static inline int local_LZ4_decompress_safe_withDict(const char* in, char* out, int inSize, int outSize) static inline int local_LZ4_decompress_safe_usingDict(const char* in, char* out, int inSize, int outSize)
{ {
(void)inSize; (void)inSize;
LZ4_decompress_safe_withDict(in, out, inSize, outSize, in - 65536, 65536); LZ4_decompress_safe_usingDict(in, out, inSize, outSize, in - 65536, 65536);
return outSize; return outSize;
} }
@ -358,8 +358,8 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
# define NB_DECOMPRESSION_ALGORITHMS 7 # define NB_DECOMPRESSION_ALGORITHMS 7
# define MINDECOMPRESSIONCHAR '0' # define MINDECOMPRESSIONCHAR '0'
# define MAXDECOMPRESSIONCHAR (MINDECOMPRESSIONCHAR + NB_DECOMPRESSION_ALGORITHMS) # define MAXDECOMPRESSIONCHAR (MINDECOMPRESSIONCHAR + NB_DECOMPRESSION_ALGORITHMS)
static char* decompressionNames[] = { "LZ4_decompress_fast", "LZ4_decompress_fast_withPrefix64k", "LZ4_decompress_fast_withDict", static char* decompressionNames[] = { "LZ4_decompress_fast", "LZ4_decompress_fast_withPrefix64k", "LZ4_decompress_fast_usingDict",
"LZ4_decompress_safe", "LZ4_decompress_safe_withPrefix64k", "LZ4_decompress_safe_withDict", "LZ4_decompress_safe_partial" }; "LZ4_decompress_safe", "LZ4_decompress_safe_withPrefix64k", "LZ4_decompress_safe_usingDict", "LZ4_decompress_safe_partial" };
double totalDTime[NB_DECOMPRESSION_ALGORITHMS] = {0}; double totalDTime[NB_DECOMPRESSION_ALGORITHMS] = {0};
U64 totals = 0; U64 totals = 0;
@ -553,10 +553,10 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
{ {
case 0: decompressionFunction = local_LZ4_decompress_fast; break; case 0: decompressionFunction = local_LZ4_decompress_fast; break;
case 1: decompressionFunction = local_LZ4_decompress_fast_withPrefix64k; break; case 1: decompressionFunction = local_LZ4_decompress_fast_withPrefix64k; break;
case 2: decompressionFunction = local_LZ4_decompress_fast_withDict; break; case 2: decompressionFunction = local_LZ4_decompress_fast_usingDict; break;
case 3: decompressionFunction = LZ4_decompress_safe; break; case 3: decompressionFunction = LZ4_decompress_safe; break;
case 4: decompressionFunction = LZ4_decompress_safe_withPrefix64k; break; case 4: decompressionFunction = LZ4_decompress_safe_withPrefix64k; break;
case 5: decompressionFunction = local_LZ4_decompress_safe_withDict; break; case 5: decompressionFunction = local_LZ4_decompress_safe_usingDict; break;
case 6: decompressionFunction = local_LZ4_decompress_safe_partial; break; case 6: decompressionFunction = local_LZ4_decompress_safe_partial; break;
default : DISPLAY("ERROR ! Bad algorithm Id !! \n"); free(chunkP); return 1; default : DISPLAY("ERROR ! Bad algorithm Id !! \n"); free(chunkP); return 1;
} }

View File

@ -412,39 +412,39 @@ int FUZ_test(U32 seed, int nbTests, double compressibility) {
// Decompress with dictionary as external // Decompress with dictionary as external
FUZ_DISPLAYTEST; FUZ_DISPLAYTEST;
decodedBuffer[blockSize] = 0; decodedBuffer[blockSize] = 0;
ret = LZ4_decompress_fast_withDict(compressedBuffer, decodedBuffer, blockSize, dict, dictSize); ret = LZ4_decompress_fast_usingDict(compressedBuffer, decodedBuffer, blockSize, dict, dictSize);
FUZ_CHECKTEST(ret!=blockContinueCompressedSize, "LZ4_decompress_fast_withDict did not read all compressed block input"); FUZ_CHECKTEST(ret!=blockContinueCompressedSize, "LZ4_decompress_fast_usingDict did not read all compressed block input");
FUZ_CHECKTEST(decodedBuffer[blockSize], "LZ4_decompress_fast_withDict overrun specified output buffer size") FUZ_CHECKTEST(decodedBuffer[blockSize], "LZ4_decompress_fast_usingDict overrun specified output buffer size")
crcCheck = XXH32(decodedBuffer, blockSize, 0); crcCheck = XXH32(decodedBuffer, blockSize, 0);
FUZ_CHECKTEST(crcCheck!=crcOrig, "LZ4_decompress_fast_withDict corrupted decoded data"); FUZ_CHECKTEST(crcCheck!=crcOrig, "LZ4_decompress_fast_usingDict corrupted decoded data");
FUZ_DISPLAYTEST; FUZ_DISPLAYTEST;
decodedBuffer[blockSize] = 0; decodedBuffer[blockSize] = 0;
ret = LZ4_decompress_safe_withDict(compressedBuffer, decodedBuffer, blockContinueCompressedSize, blockSize, dict, dictSize); ret = LZ4_decompress_safe_usingDict(compressedBuffer, decodedBuffer, blockContinueCompressedSize, blockSize, dict, dictSize);
FUZ_CHECKTEST(ret!=blockSize, "LZ4_decompress_safe_withDict did not regenerate original data"); FUZ_CHECKTEST(ret!=blockSize, "LZ4_decompress_safe_usingDict did not regenerate original data");
FUZ_CHECKTEST(decodedBuffer[blockSize], "LZ4_decompress_safe_withDict overrun specified output buffer size") FUZ_CHECKTEST(decodedBuffer[blockSize], "LZ4_decompress_safe_usingDict overrun specified output buffer size")
crcCheck = XXH32(decodedBuffer, blockSize, 0); crcCheck = XXH32(decodedBuffer, blockSize, 0);
FUZ_CHECKTEST(crcCheck!=crcOrig, "LZ4_decompress_safe_withDict corrupted decoded data"); FUZ_CHECKTEST(crcCheck!=crcOrig, "LZ4_decompress_safe_usingDict corrupted decoded data");
FUZ_DISPLAYTEST; FUZ_DISPLAYTEST;
decodedBuffer[blockSize-1] = 0; decodedBuffer[blockSize-1] = 0;
ret = LZ4_decompress_fast_withDict(compressedBuffer, decodedBuffer, blockSize-1, dict, dictSize); ret = LZ4_decompress_fast_usingDict(compressedBuffer, decodedBuffer, blockSize-1, dict, dictSize);
FUZ_CHECKTEST(ret>=0, "LZ4_decompress_fast_withDict should have failed : wrong original size (-1 byte)"); FUZ_CHECKTEST(ret>=0, "LZ4_decompress_fast_withDict should have failed : wrong original size (-1 byte)");
FUZ_CHECKTEST(decodedBuffer[blockSize-1], "LZ4_decompress_fast_withDict overrun specified output buffer size"); FUZ_CHECKTEST(decodedBuffer[blockSize-1], "LZ4_decompress_fast_usingDict overrun specified output buffer size");
FUZ_DISPLAYTEST; FUZ_DISPLAYTEST;
decodedBuffer[blockSize-1] = 0; decodedBuffer[blockSize-1] = 0;
ret = LZ4_decompress_safe_withDict(compressedBuffer, decodedBuffer, blockContinueCompressedSize, blockSize-1, dict, dictSize); ret = LZ4_decompress_safe_usingDict(compressedBuffer, decodedBuffer, blockContinueCompressedSize, blockSize-1, dict, dictSize);
FUZ_CHECKTEST(ret>=0, "LZ4_decompress_safe_withDict should have failed : not enough output size (-1 byte)"); FUZ_CHECKTEST(ret>=0, "LZ4_decompress_safe_usingDict should have failed : not enough output size (-1 byte)");
FUZ_CHECKTEST(decodedBuffer[blockSize-1], "LZ4_decompress_safe_withDict overrun specified output buffer size"); FUZ_CHECKTEST(decodedBuffer[blockSize-1], "LZ4_decompress_safe_usingDict overrun specified output buffer size");
FUZ_DISPLAYTEST; FUZ_DISPLAYTEST;
if (blockSize > 10) if (blockSize > 10)
{ {
decodedBuffer[blockSize-10] = 0; decodedBuffer[blockSize-10] = 0;
ret = LZ4_decompress_safe_withDict(compressedBuffer, decodedBuffer, blockContinueCompressedSize, blockSize-10, dict, dictSize); ret = LZ4_decompress_safe_usingDict(compressedBuffer, decodedBuffer, blockContinueCompressedSize, blockSize-10, dict, dictSize);
FUZ_CHECKTEST(ret>=0, "LZ4_decompress_safe_withDict should have failed : not enough output size (-10 byte)"); FUZ_CHECKTEST(ret>=0, "LZ4_decompress_safe_usingDict should have failed : not enough output size (-10 byte)");
FUZ_CHECKTEST(decodedBuffer[blockSize-10], "LZ4_decompress_safe_withDict overrun specified output buffer size (-10 byte) (blockSize=%i)", blockSize); FUZ_CHECKTEST(decodedBuffer[blockSize-10], "LZ4_decompress_safe_usingDict overrun specified output buffer size (-10 byte) (blockSize=%i)", blockSize);
} }