summaryrefslogtreecommitdiffstats
path: root/lib/lz4hc.c
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2018-02-20 23:25:45 (GMT)
committerYann Collet <cyan@fb.com>2018-02-20 23:25:45 (GMT)
commit25b16e8a2e51c41f5864ce5cc94ce65ab6fd52b9 (patch)
tree323bc3be488480c1ffa118f7013be8fbb197ee36 /lib/lz4hc.c
parentd3a13397d921d9d2ebae56d0503d23c73fee39b1 (diff)
downloadlz4-25b16e8a2e51c41f5864ce5cc94ce65ab6fd52b9.zip
lz4-25b16e8a2e51c41f5864ce5cc94ce65ab6fd52b9.tar.gz
lz4-25b16e8a2e51c41f5864ce5cc94ce65ab6fd52b9.tar.bz2
added one assert()
suggested by @terrelln
Diffstat (limited to 'lib/lz4hc.c')
-rw-r--r--lib/lz4hc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c
index c888ee1..f3631c5 100644
--- a/lib/lz4hc.c
+++ b/lib/lz4hc.c
@@ -135,7 +135,8 @@ int LZ4HC_countBack(const BYTE* const ip, const BYTE* const match,
/* LZ4HC_countPattern() :
* pattern32 must be a sample of repetitive pattern of length 1, 2 or 4 (but not 3!) */
-static unsigned LZ4HC_countPattern(const BYTE* ip, const BYTE* const iEnd, U32 const pattern32)
+static unsigned
+LZ4HC_countPattern(const BYTE* ip, const BYTE* const iEnd, U32 const pattern32)
{
const BYTE* const iStart = ip;
reg_t const pattern = (sizeof(pattern)==8) ? (reg_t)pattern32 + (((reg_t)pattern32) << 32) : pattern32;
@@ -167,7 +168,8 @@ static unsigned LZ4HC_countPattern(const BYTE* ip, const BYTE* const iEnd, U32 c
/* LZ4HC_reverseCountPattern() :
* pattern must be a sample of repetitive pattern of length 1, 2 or 4 (but not 3!)
* read using natural platform endianess */
-static unsigned LZ4HC_reverseCountPattern(const BYTE* ip, const BYTE* const iLow, U32 pattern)
+static unsigned
+LZ4HC_reverseCountPattern(const BYTE* ip, const BYTE* const iLow, U32 pattern)
{
const BYTE* const iStart = ip;
@@ -185,7 +187,8 @@ static unsigned LZ4HC_reverseCountPattern(const BYTE* ip, const BYTE* const iLow
typedef enum { rep_untested, rep_not, rep_confirmed } repeat_state_e;
-LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch (
+LZ4_FORCE_INLINE int
+LZ4HC_InsertAndGetWiderMatch (
LZ4HC_CCtx_internal* hc4,
const BYTE* const ip,
const BYTE* const iLowLimit,
@@ -222,6 +225,7 @@ LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch (
nbAttempts--;
if (matchIndex >= dictLimit) {
const BYTE* const matchPtr = base + matchIndex;
+ assert(longest >= 1);
if (LZ4_read16(iLowLimit + longest - 1) == LZ4_read16(matchPtr - delta + longest - 1)) {
if (LZ4_read32(matchPtr) == pattern) {
int mlt = MINMATCH + LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, iHighLimit);