summaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2019-02-21 22:05:44 +0100
committerJulius Bünger <buenger@mytum.de>2019-02-21 22:05:44 +0100
commit21494e96807553b81140769c7c69949b82592e96 (patch)
tree416af2bc14c01463b14998ee3cf44c00345632d7 /src/rps
parent7ab9e38e6652cf9d4352e8cb6073a78a773b6579 (diff)
downloadgnunet-21494e96807553b81140769c7c69949b82592e96.tar.gz
gnunet-21494e96807553b81140769c7c69949b82592e96.zip
RPS: Adapt to coding style (cosmetic only)
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/gnunet-service-rps_custommap.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/rps/gnunet-service-rps_custommap.c b/src/rps/gnunet-service-rps_custommap.c
index 18a433d6b..d3cc8d104 100644
--- a/src/rps/gnunet-service-rps_custommap.c
+++ b/src/rps/gnunet-service-rps_custommap.c
@@ -82,7 +82,8 @@ CustomPeerMap_create (unsigned int len)
82 82
83 c_peer_map = GNUNET_new (struct CustomPeerMap); 83 c_peer_map = GNUNET_new (struct CustomPeerMap);
84 c_peer_map->hash_map = GNUNET_CONTAINER_multihashmap32_create (len); 84 c_peer_map->hash_map = GNUNET_CONTAINER_multihashmap32_create (len);
85 c_peer_map->peer_map = GNUNET_CONTAINER_multipeermap_create (len, GNUNET_NO); 85 c_peer_map->peer_map = GNUNET_CONTAINER_multipeermap_create (len,
86 GNUNET_NO);
86 return c_peer_map; 87 return c_peer_map;
87} 88}
88 89
@@ -129,10 +130,16 @@ CustomPeerMap_put (const struct CustomPeerMap *c_peer_map,
129 p = GNUNET_new (struct GNUNET_PeerIdentity); 130 p = GNUNET_new (struct GNUNET_PeerIdentity);
130 *p = *peer; 131 *p = *peer;
131 GNUNET_assert (p != peer); 132 GNUNET_assert (p != peer);
132 GNUNET_assert (0 == memcmp (p, peer, sizeof(struct GNUNET_PeerIdentity))); 133 GNUNET_assert (0 == memcmp (p,
133 GNUNET_CONTAINER_multipeermap_put (c_peer_map->peer_map, p, index, 134 peer,
135 sizeof(struct GNUNET_PeerIdentity)));
136 GNUNET_CONTAINER_multipeermap_put (c_peer_map->peer_map,
137 p,
138 index,
134 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 139 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
135 GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map, *index, p, 140 GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map,
141 *index,
142 p,
136 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 143 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
137 GNUNET_assert (GNUNET_CONTAINER_multihashmap32_size (c_peer_map->hash_map) == 144 GNUNET_assert (GNUNET_CONTAINER_multihashmap32_size (c_peer_map->hash_map) ==
138 GNUNET_CONTAINER_multipeermap_size (c_peer_map->peer_map)); 145 GNUNET_CONTAINER_multipeermap_size (c_peer_map->peer_map));
@@ -194,30 +201,38 @@ CustomPeerMap_remove_peer (const struct CustomPeerMap *c_peer_map,
194 uint32_t *last_index; 201 uint32_t *last_index;
195 struct GNUNET_PeerIdentity *last_p; 202 struct GNUNET_PeerIdentity *last_p;
196 203
197 if (GNUNET_NO == CustomPeerMap_contains_peer (c_peer_map, peer)) 204 if (GNUNET_NO == CustomPeerMap_contains_peer (c_peer_map,
205 peer))
198 { 206 {
199 return GNUNET_NO; 207 return GNUNET_NO;
200 } 208 }
201 index = CustomPeerMap_get_index_pointer (c_peer_map, peer); 209 index = CustomPeerMap_get_index_pointer (c_peer_map,
210 peer);
202 GNUNET_assert (*index < CustomPeerMap_size (c_peer_map)); 211 GNUNET_assert (*index < CustomPeerMap_size (c_peer_map));
203 /* Need to get the pointer stored in the hashmap to free it */ 212 /* Need to get the pointer stored in the hashmap to free it */
204 p = GNUNET_CONTAINER_multihashmap32_get (c_peer_map->hash_map, *index); 213 p = GNUNET_CONTAINER_multihashmap32_get (c_peer_map->hash_map,
214 *index);
205 GNUNET_assert (NULL != p); 215 GNUNET_assert (NULL != p);
206 GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map, *index); 216 GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map,
217 *index);
207 // TODO wrong peerid? 218 // TODO wrong peerid?
208 GNUNET_CONTAINER_multipeermap_remove_all (c_peer_map->peer_map, peer); 219 GNUNET_CONTAINER_multipeermap_remove_all (c_peer_map->peer_map,
220 peer);
209 if (*index != CustomPeerMap_size (c_peer_map)) 221 if (*index != CustomPeerMap_size (c_peer_map))
210 { /* fill 'gap' with peer at last index */ 222 { /* fill 'gap' with peer at last index */
211 last_p = 223 last_p =
212 GNUNET_CONTAINER_multihashmap32_get (c_peer_map->hash_map, 224 GNUNET_CONTAINER_multihashmap32_get (c_peer_map->hash_map,
213 CustomPeerMap_size (c_peer_map)); 225 CustomPeerMap_size (c_peer_map));
214 GNUNET_assert (NULL != last_p); 226 GNUNET_assert (NULL != last_p);
215 last_index = GNUNET_CONTAINER_multipeermap_get (c_peer_map->peer_map, last_p); 227 last_index = GNUNET_CONTAINER_multipeermap_get (c_peer_map->peer_map,
228 last_p);
216 GNUNET_assert (NULL != last_index); 229 GNUNET_assert (NULL != last_index);
217 GNUNET_assert (CustomPeerMap_size (c_peer_map) == *last_index); 230 GNUNET_assert (CustomPeerMap_size (c_peer_map) == *last_index);
218 GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map, *index, last_p, 231 GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map,
232 *index, last_p,
219 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 233 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
220 GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map, *last_index); 234 GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map,
235 *last_index);
221 *last_index = *index; 236 *last_index = *index;
222 } 237 }
223 GNUNET_free (index); 238 GNUNET_free (index);