Browse Source

Merge pull request #61 from tobgu/master

Fix #58, block compression incompatibility with python library
Pierre Curto 6 years ago
parent
commit
edce7c4c96
2 changed files with 2 additions and 2 deletions
  1. 1 1
      block.go
  2. 1 1
      lz4.go

+ 1 - 1
block.go

@@ -124,7 +124,7 @@ func CompressBlock(src, dst []byte, hashTable []int) (_ int, err error) {
 		si, mLen = si+mLen, si+minMatch
 		si, mLen = si+mLen, si+minMatch
 
 
 		// Find the longest match by looking by batches of 8 bytes.
 		// Find the longest match by looking by batches of 8 bytes.
-		for si < sn {
+		for si+8 < sn {
 			x := binary.LittleEndian.Uint64(src[si:]) ^ binary.LittleEndian.Uint64(src[si-offset:])
 			x := binary.LittleEndian.Uint64(src[si:]) ^ binary.LittleEndian.Uint64(src[si-offset:])
 			if x == 0 {
 			if x == 0 {
 				si += 8
 				si += 8

+ 1 - 1
lz4.go

@@ -38,7 +38,7 @@ const (
 	hashLog = 16
 	hashLog = 16
 	htSize  = 1 << hashLog
 	htSize  = 1 << hashLog
 
 
-	mfLimit = 8 + minMatch // The last match cannot start within the last 12 bytes.
+	mfLimit = 10 + minMatch // The last match cannot start within the last 14 bytes.
 )
 )
 
 
 // map the block max size id with its value in bytes: 64Kb, 256Kb, 1Mb and 4Mb.
 // map the block max size id with its value in bytes: 64Kb, 256Kb, 1Mb and 4Mb.