diff options
Diffstat (limited to 'src/set/ibf.h')
-rw-r--r-- | src/set/ibf.h | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/src/set/ibf.h b/src/set/ibf.h index 94079a39f..7c2ab33b1 100644 --- a/src/set/ibf.h +++ b/src/set/ibf.h | |||
@@ -42,7 +42,8 @@ extern "C" | |||
42 | /** | 42 | /** |
43 | * Keys that can be inserted into and removed from an IBF. | 43 | * Keys that can be inserted into and removed from an IBF. |
44 | */ | 44 | */ |
45 | struct IBF_Key { | 45 | struct IBF_Key |
46 | { | ||
46 | uint64_t key_val; | 47 | uint64_t key_val; |
47 | }; | 48 | }; |
48 | 49 | ||
@@ -50,7 +51,8 @@ struct IBF_Key { | |||
50 | /** | 51 | /** |
51 | * Hash of an IBF key. | 52 | * Hash of an IBF key. |
52 | */ | 53 | */ |
53 | struct IBF_KeyHash { | 54 | struct IBF_KeyHash |
55 | { | ||
54 | uint32_t key_hash_val; | 56 | uint32_t key_hash_val; |
55 | }; | 57 | }; |
56 | 58 | ||
@@ -58,7 +60,8 @@ struct IBF_KeyHash { | |||
58 | /** | 60 | /** |
59 | * Type of the count field of IBF buckets. | 61 | * Type of the count field of IBF buckets. |
60 | */ | 62 | */ |
61 | struct IBF_Count { | 63 | struct IBF_Count |
64 | { | ||
62 | int8_t count_val; | 65 | int8_t count_val; |
63 | }; | 66 | }; |
64 | 67 | ||
@@ -66,8 +69,8 @@ struct IBF_Count { | |||
66 | /** | 69 | /** |
67 | * Size of one ibf bucket in bytes | 70 | * Size of one ibf bucket in bytes |
68 | */ | 71 | */ |
69 | #define IBF_BUCKET_SIZE (sizeof(struct IBF_Count) + sizeof(struct IBF_Key) + \ | 72 | #define IBF_BUCKET_SIZE (sizeof(struct IBF_Count) + sizeof(struct IBF_Key) \ |
70 | sizeof(struct IBF_KeyHash)) | 73 | + sizeof(struct IBF_KeyHash)) |
71 | 74 | ||
72 | 75 | ||
73 | /** | 76 | /** |
@@ -76,7 +79,8 @@ struct IBF_Count { | |||
76 | * An IBF is a counting bloom filter that has the ability to restore | 79 | * An IBF is a counting bloom filter that has the ability to restore |
77 | * the hashes of its stored elements with high probability. | 80 | * the hashes of its stored elements with high probability. |
78 | */ | 81 | */ |
79 | struct InvertibleBloomFilter { | 82 | struct InvertibleBloomFilter |
83 | { | ||
80 | /** | 84 | /** |
81 | * How many cells does this IBF have? | 85 | * How many cells does this IBF have? |
82 | */ | 86 | */ |
@@ -119,10 +123,10 @@ struct InvertibleBloomFilter { | |||
119 | * @param buf buffer to write the data to | 123 | * @param buf buffer to write the data to |
120 | */ | 124 | */ |
121 | void | 125 | void |
122 | ibf_write_slice(const struct InvertibleBloomFilter *ibf, | 126 | ibf_write_slice (const struct InvertibleBloomFilter *ibf, |
123 | uint32_t start, | 127 | uint32_t start, |
124 | uint32_t count, | 128 | uint32_t count, |
125 | void *buf); | 129 | void *buf); |
126 | 130 | ||
127 | 131 | ||
128 | /** | 132 | /** |
@@ -134,10 +138,10 @@ ibf_write_slice(const struct InvertibleBloomFilter *ibf, | |||
134 | * @param ibf the ibf to write to | 138 | * @param ibf the ibf to write to |
135 | */ | 139 | */ |
136 | void | 140 | void |
137 | ibf_read_slice(const void *buf, | 141 | ibf_read_slice (const void *buf, |
138 | uint32_t start, | 142 | uint32_t start, |
139 | uint32_t count, | 143 | uint32_t count, |
140 | struct InvertibleBloomFilter *ibf); | 144 | struct InvertibleBloomFilter *ibf); |
141 | 145 | ||
142 | 146 | ||
143 | /** | 147 | /** |
@@ -147,7 +151,7 @@ ibf_read_slice(const void *buf, | |||
147 | * @return a key | 151 | * @return a key |
148 | */ | 152 | */ |
149 | struct IBF_Key | 153 | struct IBF_Key |
150 | ibf_key_from_hashcode(const struct GNUNET_HashCode *hash); | 154 | ibf_key_from_hashcode (const struct GNUNET_HashCode *hash); |
151 | 155 | ||
152 | 156 | ||
153 | /** | 157 | /** |
@@ -158,7 +162,7 @@ ibf_key_from_hashcode(const struct GNUNET_HashCode *hash); | |||
158 | * @param dst hashcode to store the result in | 162 | * @param dst hashcode to store the result in |
159 | */ | 163 | */ |
160 | void | 164 | void |
161 | ibf_hashcode_from_key(struct IBF_Key key, struct GNUNET_HashCode *dst); | 165 | ibf_hashcode_from_key (struct IBF_Key key, struct GNUNET_HashCode *dst); |
162 | 166 | ||
163 | 167 | ||
164 | /** | 168 | /** |
@@ -169,7 +173,7 @@ ibf_hashcode_from_key(struct IBF_Key key, struct GNUNET_HashCode *dst); | |||
169 | * @return the newly created invertible bloom filter, NULL on error | 173 | * @return the newly created invertible bloom filter, NULL on error |
170 | */ | 174 | */ |
171 | struct InvertibleBloomFilter * | 175 | struct InvertibleBloomFilter * |
172 | ibf_create(uint32_t size, uint8_t hash_num); | 176 | ibf_create (uint32_t size, uint8_t hash_num); |
173 | 177 | ||
174 | 178 | ||
175 | /** | 179 | /** |
@@ -179,7 +183,7 @@ ibf_create(uint32_t size, uint8_t hash_num); | |||
179 | * @param key the element's hash code | 183 | * @param key the element's hash code |
180 | */ | 184 | */ |
181 | void | 185 | void |
182 | ibf_insert(struct InvertibleBloomFilter *ibf, struct IBF_Key key); | 186 | ibf_insert (struct InvertibleBloomFilter *ibf, struct IBF_Key key); |
183 | 187 | ||
184 | 188 | ||
185 | /** | 189 | /** |
@@ -189,7 +193,7 @@ ibf_insert(struct InvertibleBloomFilter *ibf, struct IBF_Key key); | |||
189 | * @param key the element's hash code | 193 | * @param key the element's hash code |
190 | */ | 194 | */ |
191 | void | 195 | void |
192 | ibf_remove(struct InvertibleBloomFilter *ibf, struct IBF_Key key); | 196 | ibf_remove (struct InvertibleBloomFilter *ibf, struct IBF_Key key); |
193 | 197 | ||
194 | 198 | ||
195 | /** | 199 | /** |
@@ -200,8 +204,8 @@ ibf_remove(struct InvertibleBloomFilter *ibf, struct IBF_Key key); | |||
200 | * @param ibf2 IBF that will be subtracted from ibf1 | 204 | * @param ibf2 IBF that will be subtracted from ibf1 |
201 | */ | 205 | */ |
202 | void | 206 | void |
203 | ibf_subtract(struct InvertibleBloomFilter *ibf1, | 207 | ibf_subtract (struct InvertibleBloomFilter *ibf1, |
204 | const struct InvertibleBloomFilter *ibf2); | 208 | const struct InvertibleBloomFilter *ibf2); |
205 | 209 | ||
206 | 210 | ||
207 | /** | 211 | /** |
@@ -217,9 +221,9 @@ ibf_subtract(struct InvertibleBloomFilter *ibf1, | |||
217 | * #GNUNET_SYSERR if the decoding has failed | 221 | * #GNUNET_SYSERR if the decoding has failed |
218 | */ | 222 | */ |
219 | int | 223 | int |
220 | ibf_decode(struct InvertibleBloomFilter *ibf, | 224 | ibf_decode (struct InvertibleBloomFilter *ibf, |
221 | int *ret_side, | 225 | int *ret_side, |
222 | struct IBF_Key *ret_id); | 226 | struct IBF_Key *ret_id); |
223 | 227 | ||
224 | 228 | ||
225 | /** | 229 | /** |
@@ -228,7 +232,7 @@ ibf_decode(struct InvertibleBloomFilter *ibf, | |||
228 | * @param ibf the IBF to copy | 232 | * @param ibf the IBF to copy |
229 | */ | 233 | */ |
230 | struct InvertibleBloomFilter * | 234 | struct InvertibleBloomFilter * |
231 | ibf_dup(const struct InvertibleBloomFilter *ibf); | 235 | ibf_dup (const struct InvertibleBloomFilter *ibf); |
232 | 236 | ||
233 | 237 | ||
234 | /** | 238 | /** |
@@ -238,7 +242,7 @@ ibf_dup(const struct InvertibleBloomFilter *ibf); | |||
238 | * @param ibf the intertible bloom filter to destroy | 242 | * @param ibf the intertible bloom filter to destroy |
239 | */ | 243 | */ |
240 | void | 244 | void |
241 | ibf_destroy(struct InvertibleBloomFilter *ibf); | 245 | ibf_destroy (struct InvertibleBloomFilter *ibf); |
242 | 246 | ||
243 | 247 | ||
244 | #if 0 /* keep Emacsens' auto-indent happy */ | 248 | #if 0 /* keep Emacsens' auto-indent happy */ |