summaryrefslogtreecommitdiffstats
path: root/lz4.c
diff options
context:
space:
mode:
authoryann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd>2012-08-01 23:51:55 (GMT)
committeryann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd>2012-08-01 23:51:55 (GMT)
commit89921dd39eaa4910eda636f68d3cb5f960b616ac (patch)
tree223dd85afc35f7a58f83f086d7c40465a7ac8cdf /lz4.c
parent84004b90159468e4d4984fcd6ee1dbb5ea53c982 (diff)
downloadlz4-89921dd39eaa4910eda636f68d3cb5f960b616ac.zip
lz4-89921dd39eaa4910eda636f68d3cb5f960b616ac.tar.gz
lz4-89921dd39eaa4910eda636f68d3cb5f960b616ac.tar.bz2
Fixed : small compression speed hit on GCC v4.5 introduced by r71
git-svn-id: https://lz4.googlecode.com/svn/trunk@72 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
Diffstat (limited to 'lz4.c')
-rw-r--r--lz4.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lz4.c b/lz4.c
index 0ae0c7e..1d5bfdd 100644
--- a/lz4.c
+++ b/lz4.c
@@ -319,6 +319,12 @@ inline int LZ4_NbCommonBytes (register U32 val)
// Compression functions
//******************************
+// LZ4_compressCtx :
+// -----------------
+// 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.
+// return : the number of bytes written in buffer 'dest', or 0 if the compression fails
+
inline int LZ4_compressCtx(void** ctx,
const char* source,
char* dest,
@@ -446,7 +452,7 @@ _last_literals:
// Encode Last Literals
{
int lastRun = iend - anchor;
- if (op + lastRun + 1 + ((lastRun-15)/255) >= oend) return 0;
+ if (((char*)op - dest) + lastRun + 1 + ((lastRun-15)/255) >= maxOutputSize) return 0;
if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK<<ML_BITS); lastRun-=RUN_MASK; for(; lastRun > 254 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; }
else *op++ = (lastRun<<ML_BITS);
memcpy(op, anchor, iend - anchor);
@@ -591,7 +597,7 @@ _last_literals:
// Encode Last Literals
{
int lastRun = iend - anchor;
- if (op + lastRun + 1 + ((lastRun-15)/255) >= oend) return 0;
+ if (((char*)op - dest) + lastRun + 1 + ((lastRun)>>8) >= maxOutputSize) return 0;
if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK<<ML_BITS); lastRun-=RUN_MASK; for(; lastRun > 254 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; }
else *op++ = (lastRun<<ML_BITS);
memcpy(op, anchor, iend - anchor);