forked from enlightenment/efl
Eet: update lz4 code. Fix especially compilation bug on OpenBSD
see lz4 homepage for a full description of the fixes SVN revision: 79975
This commit is contained in:
parent
88053411c6
commit
6f5a4a9a7c
|
@ -4,4 +4,4 @@ by:
|
|||
yann.collet.73@gmail.com
|
||||
Copyright/licensing info in source files here.
|
||||
|
||||
this was from revsion 66.
|
||||
this was from revision 84.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -38,6 +38,14 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
|
||||
//**************************************
|
||||
// Compiler Options
|
||||
//**************************************
|
||||
#ifdef _MSC_VER // Visual Studio
|
||||
# define inline __inline // Visual is not C99, but supports some kind of inline
|
||||
#endif
|
||||
|
||||
|
||||
//****************************
|
||||
// Simple Functions
|
||||
//****************************
|
||||
|
@ -47,22 +55,22 @@ int LZ4_uncompress (const char* source, char* dest, int osize);
|
|||
|
||||
/*
|
||||
LZ4_compress() :
|
||||
Compresses 'isize' bytes from 'source' into 'dest'.
|
||||
Destination buffer must be already allocated,
|
||||
and must be sized to handle worst cases situations (input data not compressible)
|
||||
Worst case size evaluation is provided by macro LZ4_compressBound()
|
||||
Compresses 'isize' bytes from 'source' into 'dest'.
|
||||
Destination buffer must be already allocated,
|
||||
and must be sized to handle worst cases situations (input data not compressible)
|
||||
Worst case size evaluation is provided by function LZ4_compressBound()
|
||||
|
||||
isize : is the input size. Max supported value is ~1.9GB
|
||||
return : the number of bytes written in buffer dest
|
||||
isize : is the input size. Max supported value is ~1.9GB
|
||||
return : the number of bytes written in buffer dest
|
||||
|
||||
|
||||
LZ4_uncompress() :
|
||||
osize : is the output size, therefore the original size
|
||||
return : the number of bytes read in the source buffer
|
||||
If the source stream is malformed, the function will stop decoding and return a negative result, indicating the byte position of the faulty instruction
|
||||
This function never writes beyond dest + osize, and is therefore protected against malicious data packets
|
||||
note : destination buffer must be already allocated.
|
||||
its size must be a minimum of 'osize' bytes.
|
||||
osize : is the output size, therefore the original size
|
||||
return : the number of bytes read in the source buffer
|
||||
If the source stream is malformed, the function will stop decoding and return a negative result, indicating the byte position of the faulty instruction
|
||||
This function never writes outside of provided buffers, and never modifies input buffer.
|
||||
note : destination buffer must be already allocated.
|
||||
its size must be a minimum of 'osize' bytes.
|
||||
*/
|
||||
|
||||
|
||||
|
@ -70,16 +78,19 @@ LZ4_uncompress() :
|
|||
// Advanced Functions
|
||||
//****************************
|
||||
|
||||
#define LZ4_compressBound(isize) (isize + (isize/255) + 16)
|
||||
static inline int LZ4_compressBound(int isize) { return ((isize) + ((isize)/255) + 16); }
|
||||
#define LZ4_COMPRESSBOUND( isize) ((isize) + ((isize)/255) + 16)
|
||||
|
||||
/*
|
||||
LZ4_compressBound() :
|
||||
Provides the maximum size that LZ4 may output in a "worst case" scenario (input data not compressible)
|
||||
primarily useful for memory allocation of output buffer.
|
||||
Provides the maximum size that LZ4 may output in a "worst case" scenario (input data not compressible)
|
||||
primarily useful for memory allocation of output buffer.
|
||||
inline function is recommended for the general case,
|
||||
but macro is also provided when results need to be evaluated at compile time (such as table size allocation).
|
||||
|
||||
isize : is the input size. Max supported value is ~1.9GB
|
||||
return : maximum output size in a "worst case" scenario
|
||||
note : this function is limited by "int" range (2^31-1)
|
||||
isize : is the input size. Max supported value is ~1.9GB
|
||||
return : maximum output size in a "worst case" scenario
|
||||
note : this function is limited by "int" range (2^31-1)
|
||||
*/
|
||||
|
||||
|
||||
|
@ -88,13 +99,13 @@ int LZ4_compress_limitedOutput (const char* source, char* dest, int isize, int
|
|||
/*
|
||||
LZ4_compress_limitedOutput() :
|
||||
Compress 'isize' bytes from 'source' into an output buffer 'dest' of maximum size 'maxOutputSize'.
|
||||
If it cannot achieve it, compression will stop, and result of the function will be zero.
|
||||
This function never writes outside of provided output buffer.
|
||||
If it cannot achieve it, compression will stop, and result of the function will be zero.
|
||||
This function never writes outside of provided output buffer.
|
||||
|
||||
isize : is the input size. Max supported value is ~1.9GB
|
||||
maxOutputSize : is the size of the destination buffer (which must be already allocated)
|
||||
return : the number of bytes written in buffer 'dest'
|
||||
or 0 if the compression fails
|
||||
isize : is the input size. Max supported value is ~1.9GB
|
||||
maxOutputSize : is the size of the destination buffer (which must be already allocated)
|
||||
return : the number of bytes written in buffer 'dest'
|
||||
or 0 if the compression fails
|
||||
*/
|
||||
|
||||
|
||||
|
@ -102,13 +113,13 @@ int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize,
|
|||
|
||||
/*
|
||||
LZ4_uncompress_unknownOutputSize() :
|
||||
isize : is the input size, therefore the compressed size
|
||||
maxOutputSize : is the size of the destination buffer (which must be already allocated)
|
||||
return : the number of bytes decoded in the destination buffer (necessarily <= maxOutputSize)
|
||||
If the source stream is malformed, the function will stop decoding and return a negative result, indicating the byte position of the faulty instruction
|
||||
This function never writes beyond dest + maxOutputSize, and is therefore protected against malicious data packets
|
||||
note : Destination buffer must be already allocated.
|
||||
This version is slightly slower than LZ4_uncompress()
|
||||
isize : is the input size, therefore the compressed size
|
||||
maxOutputSize : is the size of the destination buffer (which must be already allocated)
|
||||
return : the number of bytes decoded in the destination buffer (necessarily <= maxOutputSize)
|
||||
If the source stream is malformed, the function will stop decoding and return a negative result, indicating the byte position of the faulty instruction
|
||||
This function never writes beyond dest + maxOutputSize, and is therefore protected against malicious data packets
|
||||
note : Destination buffer must be already allocated.
|
||||
This version is slightly slower than LZ4_uncompress()
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -337,7 +337,7 @@ inline static int LZ4HC_InsertAndFindBestMatch (LZ4HC_Data_Structure* hc4, const
|
|||
// HC4 match finder
|
||||
LZ4HC_Insert(hc4, ip);
|
||||
ref = HASH_POINTER(ip);
|
||||
while ((ref > (ip-MAX_DISTANCE)) && (nbAttempts))
|
||||
while ((ref >= (ip-MAX_DISTANCE)) && (nbAttempts))
|
||||
{
|
||||
nbAttempts--;
|
||||
if (*(ref+ml) == *(ip+ml))
|
||||
|
@ -380,7 +380,7 @@ inline static int LZ4HC_InsertAndGetWiderMatch (LZ4HC_Data_Structure* hc4, const
|
|||
LZ4HC_Insert(hc4, ip);
|
||||
ref = HASH_POINTER(ip);
|
||||
|
||||
while ((ref > ip-MAX_DISTANCE) && (ref >= hc4->base) && (nbAttempts))
|
||||
while ((ref >= ip-MAX_DISTANCE) && (ref >= hc4->base) && (nbAttempts))
|
||||
{
|
||||
nbAttempts--;
|
||||
if (*(startLimit + longest) == *(ref - delta + longest))
|
||||
|
|
Loading…
Reference in New Issue