aboutsummaryrefslogtreecommitdiff
path: root/src/setu
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-01-19 15:50:39 +0100
committerChristian Grothoff <christian@grothoff.org>2021-01-19 15:50:39 +0100
commit5e08477d28493d40310317d5fa9d3654a3fb98b6 (patch)
treeb76ca9052d284b83d4de4de9a4ce14ec7e7be9e1 /src/setu
parent1fd0f9db27afc2fd4929b5b84529c21100f671f2 (diff)
downloadgnunet-5e08477d28493d40310317d5fa9d3654a3fb98b6.tar.gz
gnunet-5e08477d28493d40310317d5fa9d3654a3fb98b6.zip
fix bucket collision logic'
Diffstat (limited to 'src/setu')
-rw-r--r--src/setu/ibf.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/setu/ibf.c b/src/setu/ibf.c
index f079722bd..565adbbf0 100644
--- a/src/setu/ibf.c
+++ b/src/setu/ibf.c
@@ -112,7 +112,7 @@ ibf_create (uint32_t size, uint8_t hash_num)
112 112
113 113
114/** 114/**
115 * Store unique bucket indices for the specified key in dst. 115 * Store unique bucket indices for the specified @a key in @a dst.
116 */ 116 */
117static void 117static void
118ibf_get_indices (const struct InvertibleBloomFilter *ibf, 118ibf_get_indices (const struct InvertibleBloomFilter *ibf,
@@ -126,9 +126,9 @@ ibf_get_indices (const struct InvertibleBloomFilter *ibf,
126 bucket = GNUNET_CRYPTO_crc32_n (&key, sizeof key); 126 bucket = GNUNET_CRYPTO_crc32_n (&key, sizeof key);
127 for (i = 0, filled = 0; filled < ibf->hash_num; i++) 127 for (i = 0, filled = 0; filled < ibf->hash_num; i++)
128 { 128 {
129 unsigned int j;
130 uint64_t x; 129 uint64_t x;
131 for (j = 0; j < filled; j++) 130
131 for (unsigned int j = 0; j < filled; j++)
132 if (dst[j] == bucket) 132 if (dst[j] == bucket)
133 goto try_next; 133 goto try_next;
134 dst[filled++] = bucket % ibf->size; 134 dst[filled++] = bucket % ibf->size;
@@ -142,13 +142,13 @@ try_next:;
142static void 142static void
143ibf_insert_into (struct InvertibleBloomFilter *ibf, 143ibf_insert_into (struct InvertibleBloomFilter *ibf,
144 struct IBF_Key key, 144 struct IBF_Key key,
145 const int *buckets, int side) 145 const int *buckets,
146 int side)
146{ 147{
147 int i; 148 for (unsigned int i = 0; i < ibf->hash_num; i++)
148
149 for (i = 0; i < ibf->hash_num; i++)
150 { 149 {
151 const int bucket = buckets[i]; 150 const int bucket = buckets[i];
151
152 ibf->count[bucket].count_val += side; 152 ibf->count[bucket].count_val += side;
153 ibf->key_sum[bucket].key_val ^= key.key_val; 153 ibf->key_sum[bucket].key_val ^= key.key_val;
154 ibf->key_hash_sum[bucket].key_hash_val 154 ibf->key_hash_sum[bucket].key_hash_val