diff options
Diffstat (limited to 'deps/theft/theft_bloom.h')
-rw-r--r-- | deps/theft/theft_bloom.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/deps/theft/theft_bloom.h b/deps/theft/theft_bloom.h new file mode 100644 index 0000000..c5c6553 --- /dev/null +++ b/deps/theft/theft_bloom.h @@ -0,0 +1,33 @@ +#ifndef THEFT_BLOOM_H +#define THEFT_BLOOM_H + +#include <stdlib.h> +#include <stdint.h> +#include <stdbool.h> + +struct theft_bloom { + uint8_t bit_count; + size_t size; + uint8_t bits[]; +}; + +/* Initialize a bloom filter. */ +struct theft_bloom *theft_bloom_init(uint8_t bit_size2); + +/* Hash data and mark it in the bloom filter. */ +void theft_bloom_mark(struct theft_bloom *b, uint8_t *data, size_t data_size); + +/* Check whether the data's hash is in the bloom filter. */ +bool theft_bloom_check(struct theft_bloom *b, uint8_t *data, size_t data_size); + +/* Free the bloom filter. */ +void theft_bloom_free(struct theft_bloom *b); + +/* Dump the bloom filter's contents. (Debugging.) */ +void theft_bloom_dump(struct theft_bloom *b); + +/* Recommend a bloom filter size for a given number of trials. */ +uint8_t theft_bloom_recommendation(int trials); + + +#endif |