summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4.c18
-rw-r--r--lib/lz4.h4
2 files changed, 11 insertions, 11 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 7bf8677..5d4bb21 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -270,11 +270,6 @@ static void LZ4_writeLE16(void* memPtr, U16 value)
}
}
-static void LZ4_copy8(void* dst, const void* src)
-{
- memcpy(dst,src,8);
-}
-
/* customized variant of memcpy, which can overwrite up to 8 bytes beyond dstEnd */
LZ4_FORCE_O2_INLINE_GCC_PPC64LE
void LZ4_wildCopy(void* dstPtr, const void* srcPtr, void* dstEnd)
@@ -283,7 +278,7 @@ void LZ4_wildCopy(void* dstPtr, const void* srcPtr, void* dstEnd)
const BYTE* s = (const BYTE*)srcPtr;
BYTE* const e = (BYTE*)dstEnd;
- do { LZ4_copy8(d,s); d+=8; s+=8; } while (d<e);
+ do { memcpy(d,s,8); d+=8; s+=8; } while (d<e);
}
@@ -1220,10 +1215,13 @@ LZ4_FORCE_INLINE int LZ4_decompress_generic(
size_t const ll = token >> ML_BITS;
size_t const off = LZ4_readLE16(ip+ll);
const BYTE* const matchPtr = op + ll - off; /* pointer underflow risk ? */
- if ((off >= 18) /* do not deal with overlapping matches */ & (matchPtr >= lowPrefix)) {
+ if ((off >= 8) /* do not deal with overlapping matches */ & (matchPtr >= lowPrefix)) {
size_t const ml = (token & ML_MASK) + MINMATCH;
memcpy(op, ip, 16); op += ll; ip += ll + 2 /*offset*/;
- memcpy(op, matchPtr, 18); op += ml;
+ memcpy(op + 0, matchPtr + 0, 8);
+ memcpy(op + 8, matchPtr + 8, 8);
+ memcpy(op +16, matchPtr +16, 2);
+ op += ml;
continue;
}
}
@@ -1313,7 +1311,7 @@ LZ4_FORCE_INLINE int LZ4_decompress_generic(
match += inc32table[offset];
memcpy(op+4, match, 4);
match -= dec64table[offset];
- } else { LZ4_copy8(op, match); match+=8; }
+ } else { memcpy(op, match, 8); match+=8; }
op += 8;
if (unlikely(cpy>oend-12)) {
@@ -1326,7 +1324,7 @@ LZ4_FORCE_INLINE int LZ4_decompress_generic(
}
while (op<cpy) *op++ = *match++;
} else {
- LZ4_copy8(op, match);
+ memcpy(op, match, 8);
if (length>16) LZ4_wildCopy(op+8, match+8, cpy);
}
op = cpy; /* correction */
diff --git a/lib/lz4.h b/lib/lz4.h
index c5d50e2..08f06c7 100644
--- a/lib/lz4.h
+++ b/lib/lz4.h
@@ -266,7 +266,9 @@ LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, in
*
* Important : The previous 64KB of compressed data is assumed to remain preset and unmodified in memory!
* If less than 64KB has been compressed all the data must be present.
- * Special 1 : If input buffer is a double-buffer, it can have any size, including < 64 KB.
+ * Special 1 : When input is a double-buffer, they can have any size, including < 64 KB.
+ * Make sure that buffers are separated by at least one byte.
+ * This way, rule becomes simple : each block depends on previous block only.
* Special 2 : If input buffer is a ring-buffer, it can have any size, including < 64 KB.
*
* @return : size of compressed block