diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-11-27 14:14:24 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-11-27 14:14:24 +0000 |
commit | 8eac129743fb8a319b49b8344a01d618b0eb46d3 (patch) | |
tree | e6f5af012b088997bf60da7576d480dc0f429365 /src/set | |
parent | 0d3932d5151f61cf4838123dd7edc66f27c08dfc (diff) | |
download | gnunet-8eac129743fb8a319b49b8344a01d618b0eb46d3.tar.gz gnunet-8eac129743fb8a319b49b8344a01d618b0eb46d3.zip |
-dox, indentation
Diffstat (limited to 'src/set')
-rw-r--r-- | src/set/gnunet-service-set_union.c | 1 | ||||
-rw-r--r-- | src/set/gnunet-service-set_union_strata_estimator.c | 38 | ||||
-rw-r--r-- | src/set/gnunet-service-set_union_strata_estimator.h | 22 |
3 files changed, 40 insertions, 21 deletions
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c index ff056ea3c..9d90b3b33 100644 --- a/src/set/gnunet-service-set_union.c +++ b/src/set/gnunet-service-set_union.c | |||
@@ -17,7 +17,6 @@ | |||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | |||
21 | /** | 20 | /** |
22 | * @file set/gnunet-service-set_union.c | 21 | * @file set/gnunet-service-set_union.c |
23 | * @brief two-peer set operations | 22 | * @brief two-peer set operations |
diff --git a/src/set/gnunet-service-set_union_strata_estimator.c b/src/set/gnunet-service-set_union_strata_estimator.c index 2288e25f5..60ecbad7a 100644 --- a/src/set/gnunet-service-set_union_strata_estimator.c +++ b/src/set/gnunet-service-set_union_strata_estimator.c | |||
@@ -22,7 +22,6 @@ | |||
22 | * @brief invertible bloom filter | 22 | * @brief invertible bloom filter |
23 | * @author Florian Dold | 23 | * @author Florian Dold |
24 | */ | 24 | */ |
25 | |||
26 | #include "platform.h" | 25 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 26 | #include "gnunet_util_lib.h" |
28 | #include "ibf.h" | 27 | #include "ibf.h" |
@@ -36,9 +35,10 @@ | |||
36 | * @param buf buffer to write to, must be of appropriate size | 35 | * @param buf buffer to write to, must be of appropriate size |
37 | */ | 36 | */ |
38 | void | 37 | void |
39 | strata_estimator_write (const struct StrataEstimator *se, void *buf) | 38 | strata_estimator_write (const struct StrataEstimator *se, |
39 | void *buf) | ||
40 | { | 40 | { |
41 | int i; | 41 | unsigned int i; |
42 | 42 | ||
43 | GNUNET_assert (NULL != se); | 43 | GNUNET_assert (NULL != se); |
44 | for (i = 0; i < se->strata_count; i++) | 44 | for (i = 0; i < se->strata_count; i++) |
@@ -57,9 +57,11 @@ strata_estimator_write (const struct StrataEstimator *se, void *buf) | |||
57 | * @param se strata estimator to write to | 57 | * @param se strata estimator to write to |
58 | */ | 58 | */ |
59 | void | 59 | void |
60 | strata_estimator_read (const void *buf, struct StrataEstimator *se) | 60 | strata_estimator_read (const void *buf, |
61 | struct StrataEstimator *se) | ||
61 | { | 62 | { |
62 | int i; | 63 | unsigned int i; |
64 | |||
63 | for (i = 0; i < se->strata_count; i++) | 65 | for (i = 0; i < se->strata_count; i++) |
64 | { | 66 | { |
65 | ibf_read_slice (buf, 0, se->ibf_size, se->strata[i]); | 67 | ibf_read_slice (buf, 0, se->ibf_size, se->strata[i]); |
@@ -75,10 +77,12 @@ strata_estimator_read (const void *buf, struct StrataEstimator *se) | |||
75 | * @param key key to add | 77 | * @param key key to add |
76 | */ | 78 | */ |
77 | void | 79 | void |
78 | strata_estimator_insert (struct StrataEstimator *se, struct IBF_Key key) | 80 | strata_estimator_insert (struct StrataEstimator *se, |
81 | struct IBF_Key key) | ||
79 | { | 82 | { |
80 | uint64_t v; | 83 | uint64_t v; |
81 | int i; | 84 | unsigned int i; |
85 | |||
82 | v = key.key_val; | 86 | v = key.key_val; |
83 | /* count trailing '1'-bits of v */ | 87 | /* count trailing '1'-bits of v */ |
84 | for (i = 0; v & 1; v>>=1, i++) | 88 | for (i = 0; v & 1; v>>=1, i++) |
@@ -94,10 +98,12 @@ strata_estimator_insert (struct StrataEstimator *se, struct IBF_Key key) | |||
94 | * @param key key to remove | 98 | * @param key key to remove |
95 | */ | 99 | */ |
96 | void | 100 | void |
97 | strata_estimator_remove (struct StrataEstimator *se, struct IBF_Key key) | 101 | strata_estimator_remove (struct StrataEstimator *se, |
102 | struct IBF_Key key) | ||
98 | { | 103 | { |
99 | uint64_t v; | 104 | uint64_t v; |
100 | int i; | 105 | unsigned int i; |
106 | |||
101 | v = key.key_val; | 107 | v = key.key_val; |
102 | /* count trailing '1'-bits of v */ | 108 | /* count trailing '1'-bits of v */ |
103 | for (i = 0; v & 1; v>>=1, i++) | 109 | for (i = 0; v & 1; v>>=1, i++) |
@@ -115,13 +121,14 @@ strata_estimator_remove (struct StrataEstimator *se, struct IBF_Key key) | |||
115 | * @return a freshly allocated, empty strata estimator | 121 | * @return a freshly allocated, empty strata estimator |
116 | */ | 122 | */ |
117 | struct StrataEstimator * | 123 | struct StrataEstimator * |
118 | strata_estimator_create (unsigned int strata_count, uint32_t ibf_size, uint8_t ibf_hashnum) | 124 | strata_estimator_create (unsigned int strata_count, |
125 | uint32_t ibf_size, | ||
126 | uint8_t ibf_hashnum) | ||
119 | { | 127 | { |
120 | struct StrataEstimator *se; | 128 | struct StrataEstimator *se; |
121 | int i; | 129 | unsigned int i; |
122 | 130 | ||
123 | /* fixme: allocate everything in one chunk */ | 131 | /* fixme: allocate everything in one chunk */ |
124 | |||
125 | se = GNUNET_new (struct StrataEstimator); | 132 | se = GNUNET_new (struct StrataEstimator); |
126 | se->strata_count = strata_count; | 133 | se->strata_count = strata_count; |
127 | se->ibf_size = ibf_size; | 134 | se->ibf_size = ibf_size; |
@@ -146,7 +153,7 @@ strata_estimator_difference (const struct StrataEstimator *se1, | |||
146 | const struct StrataEstimator *se2) | 153 | const struct StrataEstimator *se2) |
147 | { | 154 | { |
148 | int i; | 155 | int i; |
149 | int count; | 156 | unsigned int count; |
150 | 157 | ||
151 | GNUNET_assert (se1->strata_count == se2->strata_count); | 158 | GNUNET_assert (se1->strata_count == se2->strata_count); |
152 | count = 0; | 159 | count = 0; |
@@ -155,6 +162,7 @@ strata_estimator_difference (const struct StrataEstimator *se1, | |||
155 | struct InvertibleBloomFilter *diff; | 162 | struct InvertibleBloomFilter *diff; |
156 | /* number of keys decoded from the ibf */ | 163 | /* number of keys decoded from the ibf */ |
157 | int ibf_count; | 164 | int ibf_count; |
165 | |||
158 | /* FIXME: implement this without always allocating new IBFs */ | 166 | /* FIXME: implement this without always allocating new IBFs */ |
159 | diff = ibf_dup (se1->strata[i]); | 167 | diff = ibf_dup (se1->strata[i]); |
160 | ibf_subtract (diff, se2->strata[i]); | 168 | ibf_subtract (diff, se2->strata[i]); |
@@ -191,7 +199,7 @@ struct StrataEstimator * | |||
191 | strata_estimator_dup (struct StrataEstimator *se) | 199 | strata_estimator_dup (struct StrataEstimator *se) |
192 | { | 200 | { |
193 | struct StrataEstimator *c; | 201 | struct StrataEstimator *c; |
194 | int i; | 202 | unsigned int i; |
195 | 203 | ||
196 | c = GNUNET_new (struct StrataEstimator); | 204 | c = GNUNET_new (struct StrataEstimator); |
197 | c->strata_count = se->strata_count; | 205 | c->strata_count = se->strata_count; |
@@ -211,7 +219,7 @@ strata_estimator_dup (struct StrataEstimator *se) | |||
211 | void | 219 | void |
212 | strata_estimator_destroy (struct StrataEstimator *se) | 220 | strata_estimator_destroy (struct StrataEstimator *se) |
213 | { | 221 | { |
214 | int i; | 222 | unsigned int i; |
215 | 223 | ||
216 | for (i = 0; i < se->strata_count; i++) | 224 | for (i = 0; i < se->strata_count; i++) |
217 | ibf_destroy (se->strata[i]); | 225 | ibf_destroy (se->strata[i]); |
diff --git a/src/set/gnunet-service-set_union_strata_estimator.h b/src/set/gnunet-service-set_union_strata_estimator.h index bb8d09d31..4d18db60b 100644 --- a/src/set/gnunet-service-set_union_strata_estimator.h +++ b/src/set/gnunet-service-set_union_strata_estimator.h | |||
@@ -45,8 +45,14 @@ extern "C" | |||
45 | */ | 45 | */ |
46 | struct StrataEstimator | 46 | struct StrataEstimator |
47 | { | 47 | { |
48 | |||
48 | struct InvertibleBloomFilter **strata; | 49 | struct InvertibleBloomFilter **strata; |
50 | |||
51 | /** | ||
52 | * Size of the IBF array in @e strata | ||
53 | */ | ||
49 | unsigned int strata_count; | 54 | unsigned int strata_count; |
55 | |||
50 | unsigned int ibf_size; | 56 | unsigned int ibf_size; |
51 | }; | 57 | }; |
52 | 58 | ||
@@ -58,7 +64,8 @@ struct StrataEstimator | |||
58 | * @param buf buffer to write to, must be of appropriate size | 64 | * @param buf buffer to write to, must be of appropriate size |
59 | */ | 65 | */ |
60 | void | 66 | void |
61 | strata_estimator_write (const struct StrataEstimator *se, void *buf); | 67 | strata_estimator_write (const struct StrataEstimator *se, |
68 | void *buf); | ||
62 | 69 | ||
63 | 70 | ||
64 | /** | 71 | /** |
@@ -69,7 +76,8 @@ strata_estimator_write (const struct StrataEstimator *se, void *buf); | |||
69 | * @param se strata estimator to write to | 76 | * @param se strata estimator to write to |
70 | */ | 77 | */ |
71 | void | 78 | void |
72 | strata_estimator_read (const void *buf, struct StrataEstimator *se); | 79 | strata_estimator_read (const void *buf, |
80 | struct StrataEstimator *se); | ||
73 | 81 | ||
74 | 82 | ||
75 | /** | 83 | /** |
@@ -81,7 +89,9 @@ strata_estimator_read (const void *buf, struct StrataEstimator *se); | |||
81 | * @return a freshly allocated, empty strata estimator | 89 | * @return a freshly allocated, empty strata estimator |
82 | */ | 90 | */ |
83 | struct StrataEstimator * | 91 | struct StrataEstimator * |
84 | strata_estimator_create (unsigned int strata_count, uint32_t ibf_size, uint8_t ibf_hashnum); | 92 | strata_estimator_create (unsigned int strata_count, |
93 | uint32_t ibf_size, | ||
94 | uint8_t ibf_hashnum); | ||
85 | 95 | ||
86 | 96 | ||
87 | /** | 97 | /** |
@@ -104,7 +114,8 @@ strata_estimator_difference (const struct StrataEstimator *se1, | |||
104 | * @param key key to add | 114 | * @param key key to add |
105 | */ | 115 | */ |
106 | void | 116 | void |
107 | strata_estimator_insert (struct StrataEstimator *se, struct IBF_Key key); | 117 | strata_estimator_insert (struct StrataEstimator *se, |
118 | struct IBF_Key key); | ||
108 | 119 | ||
109 | 120 | ||
110 | /** | 121 | /** |
@@ -114,7 +125,8 @@ strata_estimator_insert (struct StrataEstimator *se, struct IBF_Key key); | |||
114 | * @param key key to remove | 125 | * @param key key to remove |
115 | */ | 126 | */ |
116 | void | 127 | void |
117 | strata_estimator_remove (struct StrataEstimator *se, struct IBF_Key key); | 128 | strata_estimator_remove (struct StrataEstimator *se, |
129 | struct IBF_Key key); | ||
118 | 130 | ||
119 | 131 | ||
120 | /** | 132 | /** |