MCPcopy Create free account
hub / github.com/albertobsd/keyhunt / oldbloom_check

Function oldbloom_check

oldbloom/bloom.cpp:138–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138int oldbloom_check(struct oldbloom * bloom, const void * buffer, int len)
139{
140 if (bloom->ready == 0) {
141 printf("bloom at %p not initialized!\n", (void *)bloom);
142 return -1;
143 }
144 uint8_t hits = 0;
145 uint64_t a = XXH64(buffer, len, 0x59f2815b16f81798);
146 uint64_t b = XXH64(buffer, len, a);
147 uint64_t x;
148 uint8_t i;
149 for (i = 0; i < bloom->hashes; i++) {
150 x = (a + b*i) % bloom->bits;
151 if (oldtest_bit(bloom->bf, x)) {
152 hits++;
153 } else {
154 return 0;
155 }
156 }
157 if (hits == bloom->hashes) {
158 return 1; // 1 == element already in (or collision)
159 }
160 return 0;
161}
162
163
164int oldbloom_add(struct oldbloom * bloom, const void * buffer, int len)

Callers

nothing calls this directly

Calls 1

oldtest_bitFunction · 0.85

Tested by

no test coverage detected