aboutsummaryrefslogtreecommitdiff
path: root/src/util/container_multihashmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/container_multihashmap.c')
-rw-r--r--src/util/container_multihashmap.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/util/container_multihashmap.c b/src/util/container_multihashmap.c
index 7e53a6440..ada98251c 100644
--- a/src/util/container_multihashmap.c
+++ b/src/util/container_multihashmap.c
@@ -39,7 +39,7 @@ struct MapEntry
39 /** 39 /**
40 * Key for the entry. 40 * Key for the entry.
41 */ 41 */
42 GNUNET_HashCode key; 42 struct GNUNET_HashCode key;
43 43
44 /** 44 /**
45 * Value of the entry. 45 * Value of the entry.
@@ -130,7 +130,7 @@ GNUNET_CONTAINER_multihashmap_destroy (struct GNUNET_CONTAINER_MultiHashMap
130 */ 130 */
131static unsigned int 131static unsigned int
132idx_of (const struct GNUNET_CONTAINER_MultiHashMap *m, 132idx_of (const struct GNUNET_CONTAINER_MultiHashMap *m,
133 const GNUNET_HashCode * key) 133 const struct GNUNET_HashCode * key)
134{ 134{
135 GNUNET_assert (m != NULL); 135 GNUNET_assert (m != NULL);
136 return (*(unsigned int *) key) % m->map_length; 136 return (*(unsigned int *) key) % m->map_length;
@@ -163,14 +163,14 @@ GNUNET_CONTAINER_multihashmap_size (const struct GNUNET_CONTAINER_MultiHashMap
163 */ 163 */
164void * 164void *
165GNUNET_CONTAINER_multihashmap_get (const struct GNUNET_CONTAINER_MultiHashMap 165GNUNET_CONTAINER_multihashmap_get (const struct GNUNET_CONTAINER_MultiHashMap
166 *map, const GNUNET_HashCode * key) 166 *map, const struct GNUNET_HashCode * key)
167{ 167{
168 struct MapEntry *e; 168 struct MapEntry *e;
169 169
170 e = map->map[idx_of (map, key)]; 170 e = map->map[idx_of (map, key)];
171 while (e != NULL) 171 while (e != NULL)
172 { 172 {
173 if (0 == memcmp (key, &e->key, sizeof (GNUNET_HashCode))) 173 if (0 == memcmp (key, &e->key, sizeof (struct GNUNET_HashCode)))
174 return e->value; 174 return e->value;
175 e = e->next; 175 e = e->next;
176 } 176 }
@@ -197,7 +197,7 @@ GNUNET_CONTAINER_multihashmap_iterate (const struct
197 unsigned int i; 197 unsigned int i;
198 struct MapEntry *e; 198 struct MapEntry *e;
199 struct MapEntry *n; 199 struct MapEntry *n;
200 GNUNET_HashCode kc; 200 struct GNUNET_HashCode kc;
201 201
202 count = 0; 202 count = 0;
203 GNUNET_assert (map != NULL); 203 GNUNET_assert (map != NULL);
@@ -233,7 +233,7 @@ GNUNET_CONTAINER_multihashmap_iterate (const struct
233 */ 233 */
234int 234int
235GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map, 235GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map,
236 const GNUNET_HashCode * key, void *value) 236 const struct GNUNET_HashCode * key, void *value)
237{ 237{
238 struct MapEntry *e; 238 struct MapEntry *e;
239 struct MapEntry *p; 239 struct MapEntry *p;
@@ -244,7 +244,7 @@ GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map,
244 e = map->map[i]; 244 e = map->map[i];
245 while (e != NULL) 245 while (e != NULL)
246 { 246 {
247 if ((0 == memcmp (key, &e->key, sizeof (GNUNET_HashCode))) && 247 if ((0 == memcmp (key, &e->key, sizeof (struct GNUNET_HashCode))) &&
248 (value == e->value)) 248 (value == e->value))
249 { 249 {
250 if (p == NULL) 250 if (p == NULL)
@@ -272,7 +272,7 @@ GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map,
272 */ 272 */
273int 273int
274GNUNET_CONTAINER_multihashmap_remove_all (struct GNUNET_CONTAINER_MultiHashMap 274GNUNET_CONTAINER_multihashmap_remove_all (struct GNUNET_CONTAINER_MultiHashMap
275 *map, const GNUNET_HashCode * key) 275 *map, const struct GNUNET_HashCode * key)
276{ 276{
277 struct MapEntry *e; 277 struct MapEntry *e;
278 struct MapEntry *p; 278 struct MapEntry *p;
@@ -285,7 +285,7 @@ GNUNET_CONTAINER_multihashmap_remove_all (struct GNUNET_CONTAINER_MultiHashMap
285 e = map->map[i]; 285 e = map->map[i];
286 while (e != NULL) 286 while (e != NULL)
287 { 287 {
288 if (0 == memcmp (key, &e->key, sizeof (GNUNET_HashCode))) 288 if (0 == memcmp (key, &e->key, sizeof (struct GNUNET_HashCode)))
289 { 289 {
290 if (p == NULL) 290 if (p == NULL)
291 map->map[i] = e->next; 291 map->map[i] = e->next;
@@ -321,14 +321,14 @@ GNUNET_CONTAINER_multihashmap_remove_all (struct GNUNET_CONTAINER_MultiHashMap
321int 321int
322GNUNET_CONTAINER_multihashmap_contains (const struct 322GNUNET_CONTAINER_multihashmap_contains (const struct
323 GNUNET_CONTAINER_MultiHashMap *map, 323 GNUNET_CONTAINER_MultiHashMap *map,
324 const GNUNET_HashCode * key) 324 const struct GNUNET_HashCode * key)
325{ 325{
326 struct MapEntry *e; 326 struct MapEntry *e;
327 327
328 e = map->map[idx_of (map, key)]; 328 e = map->map[idx_of (map, key)];
329 while (e != NULL) 329 while (e != NULL)
330 { 330 {
331 if (0 == memcmp (key, &e->key, sizeof (GNUNET_HashCode))) 331 if (0 == memcmp (key, &e->key, sizeof (struct GNUNET_HashCode)))
332 return GNUNET_YES; 332 return GNUNET_YES;
333 e = e->next; 333 e = e->next;
334 } 334 }
@@ -349,7 +349,7 @@ GNUNET_CONTAINER_multihashmap_contains (const struct
349int 349int
350GNUNET_CONTAINER_multihashmap_contains_value (const struct 350GNUNET_CONTAINER_multihashmap_contains_value (const struct
351 GNUNET_CONTAINER_MultiHashMap 351 GNUNET_CONTAINER_MultiHashMap
352 *map, const GNUNET_HashCode * key, 352 *map, const struct GNUNET_HashCode * key,
353 const void *value) 353 const void *value)
354{ 354{
355 struct MapEntry *e; 355 struct MapEntry *e;
@@ -357,7 +357,7 @@ GNUNET_CONTAINER_multihashmap_contains_value (const struct
357 e = map->map[idx_of (map, key)]; 357 e = map->map[idx_of (map, key)];
358 while (e != NULL) 358 while (e != NULL)
359 { 359 {
360 if ((0 == memcmp (key, &e->key, sizeof (GNUNET_HashCode))) && 360 if ((0 == memcmp (key, &e->key, sizeof (struct GNUNET_HashCode))) &&
361 (e->value == value)) 361 (e->value == value))
362 return GNUNET_YES; 362 return GNUNET_YES;
363 e = e->next; 363 e = e->next;
@@ -416,7 +416,7 @@ grow (struct GNUNET_CONTAINER_MultiHashMap *map)
416 */ 416 */
417int 417int
418GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map, 418GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map,
419 const GNUNET_HashCode * key, void *value, 419 const struct GNUNET_HashCode * key, void *value,
420 enum GNUNET_CONTAINER_MultiHashMapOption opt) 420 enum GNUNET_CONTAINER_MultiHashMapOption opt)
421{ 421{
422 struct MapEntry *e; 422 struct MapEntry *e;
@@ -429,7 +429,7 @@ GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map,
429 e = map->map[i]; 429 e = map->map[i];
430 while (e != NULL) 430 while (e != NULL)
431 { 431 {
432 if (0 == memcmp (key, &e->key, sizeof (GNUNET_HashCode))) 432 if (0 == memcmp (key, &e->key, sizeof (struct GNUNET_HashCode)))
433 { 433 {
434 if (opt == GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) 434 if (opt == GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)
435 return GNUNET_SYSERR; 435 return GNUNET_SYSERR;
@@ -467,7 +467,7 @@ GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map,
467int 467int
468GNUNET_CONTAINER_multihashmap_get_multiple (const struct 468GNUNET_CONTAINER_multihashmap_get_multiple (const struct
469 GNUNET_CONTAINER_MultiHashMap *map, 469 GNUNET_CONTAINER_MultiHashMap *map,
470 const GNUNET_HashCode * key, 470 const struct GNUNET_HashCode * key,
471 GNUNET_CONTAINER_HashMapIterator it, 471 GNUNET_CONTAINER_HashMapIterator it,
472 void *it_cls) 472 void *it_cls)
473{ 473{
@@ -480,7 +480,7 @@ GNUNET_CONTAINER_multihashmap_get_multiple (const struct
480 while (NULL != (e = n)) 480 while (NULL != (e = n))
481 { 481 {
482 n = e->next; 482 n = e->next;
483 if (0 != memcmp (key, &e->key, sizeof (GNUNET_HashCode))) 483 if (0 != memcmp (key, &e->key, sizeof (struct GNUNET_HashCode)))
484 continue; 484 continue;
485 if ((it != NULL) && (GNUNET_OK != it (it_cls, key, e->value))) 485 if ((it != NULL) && (GNUNET_OK != it (it_cls, key, e->value)))
486 return GNUNET_SYSERR; 486 return GNUNET_SYSERR;