Browse code

Add theft

John Hawthorn authored on 03/04/2017 09:11:20
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,33 @@
1
+#ifndef THEFT_BLOOM_H
2
+#define THEFT_BLOOM_H
3
+
4
+#include <stdlib.h>
5
+#include <stdint.h>
6
+#include <stdbool.h>
7
+
8
+struct theft_bloom {
9
+    uint8_t bit_count;
10
+    size_t size;
11
+    uint8_t bits[];
12
+};
13
+
14
+/* Initialize a bloom filter. */
15
+struct theft_bloom *theft_bloom_init(uint8_t bit_size2);
16
+
17
+/* Hash data and mark it in the bloom filter. */
18
+void theft_bloom_mark(struct theft_bloom *b, uint8_t *data, size_t data_size);
19
+
20
+/* Check whether the data's hash is in the bloom filter. */
21
+bool theft_bloom_check(struct theft_bloom *b, uint8_t *data, size_t data_size);
22
+
23
+/* Free the bloom filter. */
24
+void theft_bloom_free(struct theft_bloom *b);
25
+
26
+/* Dump the bloom filter's contents. (Debugging.) */
27
+void theft_bloom_dump(struct theft_bloom *b);
28
+
29
+/* Recommend a bloom filter size for a given number of trials. */
30
+uint8_t theft_bloom_recommendation(int trials);
31
+
32
+
33
+#endif