reindent bloom.c
This commit is contained in:
parent
bc13bda65b
commit
ba7633d4e0
1 changed files with 15 additions and 15 deletions
30
bloom.c
30
bloom.c
|
@ -8,7 +8,7 @@
|
|||
*
|
||||
* See http://isthe.com/chongo/tech/comp/fnv/
|
||||
*/
|
||||
uint32_t fnv32_1(uint8_t *data, size_t data_len) {
|
||||
uint32_t fnv32_1(uint8_t * data, size_t data_len) {
|
||||
uint32_t hash;
|
||||
|
||||
/* Constants, for 32-bit only. */
|
||||
|
@ -17,8 +17,8 @@ uint32_t fnv32_1(uint8_t *data, size_t data_len) {
|
|||
|
||||
hash = offset_basis;
|
||||
for (size_t i = 0; i < data_len; i++) {
|
||||
hash = hash * FNV_prime; /* implictly modulo 2^32 */
|
||||
hash = hash ^ data[i]; /* implictly only on lower octet. */
|
||||
hash = hash * FNV_prime; /* implictly modulo 2^32 */
|
||||
hash = hash ^ data[i]; /* implictly only on lower octet. */
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
@ -30,17 +30,17 @@ uint32_t fnv32_1_str(char *string) {
|
|||
|
||||
int main(void) {
|
||||
/* Test FNV32_1 */
|
||||
assert(fnv32_1_str("03SB[") == 0x00000000UL);
|
||||
assert(fnv32_1_str("") == 0x811c9dc5UL);
|
||||
assert(fnv32_1_str("a") == 0x050c5d7eUL);
|
||||
assert(fnv32_1_str("b") == 0x050c5d7dUL);
|
||||
assert(fnv32_1_str("c") == 0x050c5d7cUL);
|
||||
assert(fnv32_1_str("d") == 0x050c5d7bUL);
|
||||
assert(fnv32_1_str("e") == 0x050c5d7aUL);
|
||||
assert(fnv32_1_str("f") == 0x050c5d79UL);
|
||||
assert(fnv32_1_str("fo") == 0x6b772514UL);
|
||||
assert(fnv32_1_str("foo") == 0x408f5e13UL);
|
||||
assert(fnv32_1_str("foob") == 0xb4b1178bUL);
|
||||
assert(fnv32_1_str("fooba") == 0xfdc80fb0UL);
|
||||
assert(fnv32_1_str("03SB[") == 0x00000000UL);
|
||||
assert(fnv32_1_str("") == 0x811c9dc5UL);
|
||||
assert(fnv32_1_str("a") == 0x050c5d7eUL);
|
||||
assert(fnv32_1_str("b") == 0x050c5d7dUL);
|
||||
assert(fnv32_1_str("c") == 0x050c5d7cUL);
|
||||
assert(fnv32_1_str("d") == 0x050c5d7bUL);
|
||||
assert(fnv32_1_str("e") == 0x050c5d7aUL);
|
||||
assert(fnv32_1_str("f") == 0x050c5d79UL);
|
||||
assert(fnv32_1_str("fo") == 0x6b772514UL);
|
||||
assert(fnv32_1_str("foo") == 0x408f5e13UL);
|
||||
assert(fnv32_1_str("foob") == 0xb4b1178bUL);
|
||||
assert(fnv32_1_str("fooba") == 0xfdc80fb0UL);
|
||||
assert(fnv32_1_str("foobar") == 0x31f0b262UL);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue