summaryrefslogtreecommitdiff
path: root/deps/theft/theft_bloom.h
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2017-04-03 02:11:20 -0700
committerJohn Hawthorn <john.hawthorn@gmail.com>2017-04-03 02:12:33 -0700
commitdfe82eb18d19f7cde3c0f0099718af06c94c314c (patch)
tree21e0b728d9119dbfaabe11d4d33fba7ce8047bdf /deps/theft/theft_bloom.h
parent13eb8385d4cc4e943a88a97c348385620f20efc6 (diff)
Add theft
Diffstat (limited to 'deps/theft/theft_bloom.h')
-rw-r--r--deps/theft/theft_bloom.h33
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