mirror of
https://github.com/lz4/lz4.git
synced 2024-12-01 13:53:25 +08:00
Removed LZ4_decode() function code.
If you need to provide "isize" instead of "osize" to the decoder, please use LZ4_uncompress_unknownOutputSize(), which is safer. git-svn-id: https://lz4.googlecode.com/svn/trunk@12 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
This commit is contained in:
parent
a201020317
commit
8860e61b4f
56
lz4.c
56
lz4.c
@ -371,59 +371,3 @@ _output_error:
|
||||
}
|
||||
|
||||
|
||||
//****************************
|
||||
// Deprecated functions
|
||||
//****************************
|
||||
int LZ4_decode ( char* source,
|
||||
char* dest,
|
||||
int isize)
|
||||
{
|
||||
// Local Variables
|
||||
BYTE *ip = (BYTE*)source,
|
||||
*iend = ip + isize;
|
||||
|
||||
BYTE *op = (BYTE*)dest,
|
||||
*ref, *cpy,
|
||||
runcode;
|
||||
|
||||
U32 dec[4]={0, 3, 2, 3};
|
||||
int len, length;
|
||||
|
||||
|
||||
// Main Loop
|
||||
while (ip < iend)
|
||||
{
|
||||
// get runlength
|
||||
runcode = *ip++;
|
||||
if ((length=(runcode>>ML_BITS)) == RUN_MASK) { for (;(len=*ip++)==255;length+=255){} length += len; }
|
||||
|
||||
// copy literals
|
||||
ref=op+length;
|
||||
while (op<ref) { *(U32*)op = *(U32*)ip; op+=4; ip+=4; }
|
||||
ip-=(op-ref); op=ref; // correction
|
||||
if (ip>=iend) break; // Check EOF
|
||||
|
||||
// get offset
|
||||
ref -= *(U16*)ip; ip+=2;
|
||||
|
||||
// get matchlength
|
||||
if ((length=(runcode&ML_MASK)) == ML_MASK) { for (;(len=*ip++)==255;length+=255){} length += len; }
|
||||
length += MINMATCH;
|
||||
|
||||
// copy repeated sequence
|
||||
cpy = op + length;
|
||||
if (op-ref<4)
|
||||
{
|
||||
*op++ = *ref++;
|
||||
*op++ = *ref++;
|
||||
*op++ = *ref++;
|
||||
*op++ = *ref++;
|
||||
ref -= dec[op-ref];
|
||||
} else { *(U32*)op=*(U32*)ref; op+=4; ref+=4; }
|
||||
while(op<cpy) { *(U32*)op=*(U32*)ref; op+=4; ref+=4; }
|
||||
op=cpy; // correction
|
||||
}
|
||||
|
||||
// end of decoding
|
||||
return (int) (((char*)op)-dest);
|
||||
}
|
||||
|
13
lz4.h
13
lz4.h
@ -92,18 +92,9 @@ LZ4_compressCtx :
|
||||
// Deprecated decoding function
|
||||
//*********************************
|
||||
|
||||
int LZ4_decode (char* source, char* dest, int isize);
|
||||
|
||||
/*
|
||||
LZ4_decode : This version is faster, but deprecated
|
||||
return : the number of bytes in decoded buffer dest
|
||||
note 1 : isize is the input size, therefore the compressed size
|
||||
note 2 : destination buffer must be already allocated.
|
||||
The program calling the decoder must know in advance the size of decoded stream to properly allocate the destination buffer
|
||||
The destination buffer size must be at least "decompressedSize + 3 Bytes"
|
||||
This version is **unprotected** against malicious data packets designed to create buffer overflow errors.
|
||||
It is therefore not recommended in unsecure situations, such as Internet communications.
|
||||
This function is deprecated.
|
||||
LZ4_decode : Starting with r12, LZ4_decode() is no longer provided in LZ4 source code.
|
||||
If you need to provide "isize" instead of "osize" to the decoder, please use LZ4_uncompress_unknownOutputSize(), which is safer.
|
||||
*/
|
||||
|
||||
|
||||
|
13
main.c
13
main.c
@ -54,7 +54,7 @@
|
||||
// Constants
|
||||
//****************************
|
||||
#define COMPRESSOR_NAME "Demo compression program using LZ4"
|
||||
#define COMPRESSOR_VERSION "v1.0"
|
||||
#define COMPRESSOR_VERSION ""
|
||||
#define COMPILED __DATE__
|
||||
#define AUTHOR "Yann Collet"
|
||||
#define BINARY_NAME "LZ4.exe"
|
||||
@ -75,7 +75,7 @@
|
||||
int usage()
|
||||
{
|
||||
printf("Usage :\n");
|
||||
printf(" %s [arg] input [output]\n",BINARY_NAME);
|
||||
printf(" %s [arg] input output\n",BINARY_NAME);
|
||||
printf("Arguments :\n");
|
||||
printf(" -c : force compression (default)\n");
|
||||
printf(" -d : force decompression \n");
|
||||
@ -227,16 +227,13 @@ int main(int argc, char** argv)
|
||||
argument += command;
|
||||
|
||||
// display help on usage
|
||||
if( argument[0] =='h' )
|
||||
{ usage(); return 0; }
|
||||
if ( argument[0] =='h' ) { usage(); return 0; }
|
||||
|
||||
// Forced Compression (default)
|
||||
if( argument[0] =='c' )
|
||||
{ compression=1; continue; }
|
||||
if ( argument[0] =='c' ) { compression=1; continue; }
|
||||
|
||||
// Forced Decoding
|
||||
if( argument[0] =='d' )
|
||||
{ decode=1; continue; }
|
||||
if ( argument[0] =='d' ) { decode=1; continue; }
|
||||
}
|
||||
|
||||
// first provided filename is input
|
||||
|
Loading…
Reference in New Issue
Block a user