Browse Source

Merge remote-tracking branch 'upstream/master' into parser

DanielGavin 4 years ago
parent
commit
c429c85ade
2 changed files with 6 additions and 6 deletions
  1. 4 4
      core/hash/crc.odin
  2. 2 2
      core/hash/hash.odin

+ 4 - 4
core/hash/crc.odin

@@ -1,14 +1,14 @@
 package hash
 package hash
 
 
-crc32 :: proc(data: []byte) -> u32 #no_bounds_check {
-	result := ~u32(0);
+crc32 :: proc(data: []byte, seed := u32(0)) -> u32 #no_bounds_check {
+	result := ~u32(seed);
 	for b in data {
 	for b in data {
 		result = result>>8 ~ _crc32_table[(result ~ u32(b)) & 0xff];
 		result = result>>8 ~ _crc32_table[(result ~ u32(b)) & 0xff];
 	}
 	}
 	return ~result;
 	return ~result;
 }
 }
-crc64 :: proc(data: []byte) -> u64 #no_bounds_check {
-	result := ~u64(0);
+crc64 :: proc(data: []byte, seed := u32(0)) -> u64 #no_bounds_check {
+	result := ~u64(seed);
 	for b in data {
 	for b in data {
 		result = result>>8 ~ _crc64_table[(result ~ u64(b)) & 0xff];
 		result = result>>8 ~ _crc64_table[(result ~ u64(b)) & 0xff];
 	}
 	}

+ 2 - 2
core/hash/hash.odin

@@ -2,9 +2,9 @@ package hash
 
 
 import "core:mem"
 import "core:mem"
 
 
-adler32 :: proc(data: []byte) -> u32 {
+adler32 :: proc(data: []byte, seed := u32(1)) -> u32 {
 	ADLER_CONST :: 65521;
 	ADLER_CONST :: 65521;
-	a, b: u32 = 1, 0;
+	a, b: u32 = seed & 0xFFFF, seed >> 16;
 	for x in data {
 	for x in data {
 		a = (a + u32(x)) % ADLER_CONST;
 		a = (a + u32(x)) % ADLER_CONST;
 		b = (b + a) % ADLER_CONST;
 		b = (b + a) % ADLER_CONST;