aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_container_lib.h18
-rw-r--r--src/util/container_multishortmap.c53
2 files changed, 36 insertions, 35 deletions
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h
index c99b911a1..f3aaa943b 100644
--- a/src/include/gnunet_container_lib.h
+++ b/src/include/gnunet_container_lib.h
@@ -1300,7 +1300,7 @@ GNUNET_CONTAINER_multipeermap_get_random (const struct GNUNET_CONTAINER_MultiPee
1300 */ 1300 */
1301typedef int 1301typedef int
1302(*GNUNET_CONTAINER_ShortmapIterator) (void *cls, 1302(*GNUNET_CONTAINER_ShortmapIterator) (void *cls,
1303 const struct GNUNET_PeerIdentity *key, 1303 const struct GNUNET_ShortHashCode *key,
1304 void *value); 1304 void *value);
1305 1305
1306 1306
@@ -1355,7 +1355,7 @@ GNUNET_CONTAINER_multishortmap_destroy (struct GNUNET_CONTAINER_MultiShortmap *m
1355 */ 1355 */
1356void * 1356void *
1357GNUNET_CONTAINER_multishortmap_get (const struct GNUNET_CONTAINER_MultiShortmap *map, 1357GNUNET_CONTAINER_multishortmap_get (const struct GNUNET_CONTAINER_MultiShortmap *map,
1358 const struct GNUNET_PeerIdentity *key); 1358 const struct GNUNET_ShortHashCode *key);
1359 1359
1360 1360
1361/** 1361/**
@@ -1372,7 +1372,7 @@ GNUNET_CONTAINER_multishortmap_get (const struct GNUNET_CONTAINER_MultiShortmap
1372 */ 1372 */
1373int 1373int
1374GNUNET_CONTAINER_multishortmap_remove (struct GNUNET_CONTAINER_MultiShortmap *map, 1374GNUNET_CONTAINER_multishortmap_remove (struct GNUNET_CONTAINER_MultiShortmap *map,
1375 const struct GNUNET_PeerIdentity * key, 1375 const struct GNUNET_ShortHashCode * key,
1376 const void *value); 1376 const void *value);
1377 1377
1378/** 1378/**
@@ -1386,7 +1386,7 @@ GNUNET_CONTAINER_multishortmap_remove (struct GNUNET_CONTAINER_MultiShortmap *ma
1386 */ 1386 */
1387int 1387int
1388GNUNET_CONTAINER_multishortmap_remove_all (struct GNUNET_CONTAINER_MultiShortmap *map, 1388GNUNET_CONTAINER_multishortmap_remove_all (struct GNUNET_CONTAINER_MultiShortmap *map,
1389 const struct GNUNET_PeerIdentity *key); 1389 const struct GNUNET_ShortHashCode *key);
1390 1390
1391 1391
1392/** 1392/**
@@ -1401,7 +1401,7 @@ GNUNET_CONTAINER_multishortmap_remove_all (struct GNUNET_CONTAINER_MultiShortmap
1401 */ 1401 */
1402int 1402int
1403GNUNET_CONTAINER_multishortmap_contains (const struct GNUNET_CONTAINER_MultiShortmap *map, 1403GNUNET_CONTAINER_multishortmap_contains (const struct GNUNET_CONTAINER_MultiShortmap *map,
1404 const struct GNUNET_PeerIdentity *key); 1404 const struct GNUNET_ShortHashCode *key);
1405 1405
1406 1406
1407/** 1407/**
@@ -1417,7 +1417,7 @@ GNUNET_CONTAINER_multishortmap_contains (const struct GNUNET_CONTAINER_MultiShor
1417 */ 1417 */
1418int 1418int
1419GNUNET_CONTAINER_multishortmap_contains_value (const struct GNUNET_CONTAINER_MultiShortmap *map, 1419GNUNET_CONTAINER_multishortmap_contains_value (const struct GNUNET_CONTAINER_MultiShortmap *map,
1420 const struct GNUNET_PeerIdentity * key, 1420 const struct GNUNET_ShortHashCode * key,
1421 const void *value); 1421 const void *value);
1422 1422
1423 1423
@@ -1436,7 +1436,7 @@ GNUNET_CONTAINER_multishortmap_contains_value (const struct GNUNET_CONTAINER_Mul
1436 */ 1436 */
1437int 1437int
1438GNUNET_CONTAINER_multishortmap_put (struct GNUNET_CONTAINER_MultiShortmap *map, 1438GNUNET_CONTAINER_multishortmap_put (struct GNUNET_CONTAINER_MultiShortmap *map,
1439 const struct GNUNET_PeerIdentity *key, 1439 const struct GNUNET_ShortHashCode *key,
1440 void *value, 1440 void *value,
1441 enum GNUNET_CONTAINER_MultiHashMapOption opt); 1441 enum GNUNET_CONTAINER_MultiHashMapOption opt);
1442 1442
@@ -1505,7 +1505,7 @@ GNUNET_CONTAINER_multishortmap_iterator_create (const struct GNUNET_CONTAINER_Mu
1505 */ 1505 */
1506int 1506int
1507GNUNET_CONTAINER_multishortmap_iterator_next (struct GNUNET_CONTAINER_MultiShortmapIterator *iter, 1507GNUNET_CONTAINER_multishortmap_iterator_next (struct GNUNET_CONTAINER_MultiShortmapIterator *iter,
1508 struct GNUNET_PeerIdentity *key, 1508 struct GNUNET_ShortHashCode *key,
1509 const void **value); 1509 const void **value);
1510 1510
1511 1511
@@ -1532,7 +1532,7 @@ GNUNET_CONTAINER_multishortmap_iterator_destroy (struct GNUNET_CONTAINER_MultiSh
1532 */ 1532 */
1533int 1533int
1534GNUNET_CONTAINER_multishortmap_get_multiple (const struct GNUNET_CONTAINER_MultiShortmap *map, 1534GNUNET_CONTAINER_multishortmap_get_multiple (const struct GNUNET_CONTAINER_MultiShortmap *map,
1535 const struct GNUNET_PeerIdentity *key, 1535 const struct GNUNET_ShortHashCode *key,
1536 GNUNET_CONTAINER_ShortmapIterator it, 1536 GNUNET_CONTAINER_ShortmapIterator it,
1537 void *it_cls); 1537 void *it_cls);
1538 1538
diff --git a/src/util/container_multishortmap.c b/src/util/container_multishortmap.c
index 71d1073b0..5e8a47b09 100644
--- a/src/util/container_multishortmap.c
+++ b/src/util/container_multishortmap.c
@@ -47,7 +47,7 @@ struct BigMapEntry
47 /** 47 /**
48 * Key for the entry. 48 * Key for the entry.
49 */ 49 */
50 struct GNUNET_PeerIdentity key; 50 struct GNUNET_ShortHashCode key;
51 51
52}; 52};
53 53
@@ -71,7 +71,7 @@ struct SmallMapEntry
71 /** 71 /**
72 * Key for the entry. 72 * Key for the entry.
73 */ 73 */
74 const struct GNUNET_PeerIdentity *key; 74 const struct GNUNET_ShortHashCode *key;
75 75
76}; 76};
77 77
@@ -243,7 +243,7 @@ GNUNET_CONTAINER_multishortmap_destroy (struct GNUNET_CONTAINER_MultiShortmap
243 */ 243 */
244static unsigned int 244static unsigned int
245idx_of (const struct GNUNET_CONTAINER_MultiShortmap *map, 245idx_of (const struct GNUNET_CONTAINER_MultiShortmap *map,
246 const struct GNUNET_PeerIdentity *key) 246 const struct GNUNET_ShortHashCode *key)
247{ 247{
248 unsigned int kx; 248 unsigned int kx;
249 249
@@ -278,7 +278,7 @@ GNUNET_CONTAINER_multishortmap_size (const struct GNUNET_CONTAINER_MultiShortmap
278 */ 278 */
279void * 279void *
280GNUNET_CONTAINER_multishortmap_get (const struct GNUNET_CONTAINER_MultiShortmap *map, 280GNUNET_CONTAINER_multishortmap_get (const struct GNUNET_CONTAINER_MultiShortmap *map,
281 const struct GNUNET_PeerIdentity *key) 281 const struct GNUNET_ShortHashCode *key)
282{ 282{
283 union MapEntry me; 283 union MapEntry me;
284 284
@@ -288,7 +288,7 @@ GNUNET_CONTAINER_multishortmap_get (const struct GNUNET_CONTAINER_MultiShortmap
288 struct SmallMapEntry *sme; 288 struct SmallMapEntry *sme;
289 289
290 for (sme = me.sme; NULL != sme; sme = sme->next) 290 for (sme = me.sme; NULL != sme; sme = sme->next)
291 if (0 == memcmp (key, sme->key, sizeof (struct GNUNET_PeerIdentity))) 291 if (0 == memcmp (key, sme->key, sizeof (struct GNUNET_ShortHashCode)))
292 return sme->value; 292 return sme->value;
293 } 293 }
294 else 294 else
@@ -296,7 +296,7 @@ GNUNET_CONTAINER_multishortmap_get (const struct GNUNET_CONTAINER_MultiShortmap
296 struct BigMapEntry *bme; 296 struct BigMapEntry *bme;
297 297
298 for (bme = me.bme; NULL != bme; bme = bme->next) 298 for (bme = me.bme; NULL != bme; bme = bme->next)
299 if (0 == memcmp (key, &bme->key, sizeof (struct GNUNET_PeerIdentity))) 299 if (0 == memcmp (key, &bme->key, sizeof (struct GNUNET_ShortHashCode)))
300 return bme->value; 300 return bme->value;
301 } 301 }
302 return NULL; 302 return NULL;
@@ -320,7 +320,7 @@ GNUNET_CONTAINER_multishortmap_iterate (const struct GNUNET_CONTAINER_MultiShort
320 int count; 320 int count;
321 unsigned int i; 321 unsigned int i;
322 union MapEntry me; 322 union MapEntry me;
323 struct GNUNET_PeerIdentity kc; 323 struct GNUNET_ShortHashCode kc;
324 324
325 count = 0; 325 count = 0;
326 GNUNET_assert (NULL != map); 326 GNUNET_assert (NULL != map);
@@ -380,7 +380,7 @@ GNUNET_CONTAINER_multishortmap_iterate (const struct GNUNET_CONTAINER_MultiShort
380 */ 380 */
381int 381int
382GNUNET_CONTAINER_multishortmap_remove (struct GNUNET_CONTAINER_MultiShortmap *map, 382GNUNET_CONTAINER_multishortmap_remove (struct GNUNET_CONTAINER_MultiShortmap *map,
383 const struct GNUNET_PeerIdentity *key, 383 const struct GNUNET_ShortHashCode *key,
384 const void *value) 384 const void *value)
385{ 385{
386 union MapEntry me; 386 union MapEntry me;
@@ -398,7 +398,7 @@ GNUNET_CONTAINER_multishortmap_remove (struct GNUNET_CONTAINER_MultiShortmap *ma
398 p = NULL; 398 p = NULL;
399 for (sme = me.sme; NULL != sme; sme = sme->next) 399 for (sme = me.sme; NULL != sme; sme = sme->next)
400 { 400 {
401 if ((0 == memcmp (key, sme->key, sizeof (struct GNUNET_PeerIdentity))) && 401 if ((0 == memcmp (key, sme->key, sizeof (struct GNUNET_ShortHashCode))) &&
402 (value == sme->value)) 402 (value == sme->value))
403 { 403 {
404 if (NULL == p) 404 if (NULL == p)
@@ -420,7 +420,7 @@ GNUNET_CONTAINER_multishortmap_remove (struct GNUNET_CONTAINER_MultiShortmap *ma
420 p = NULL; 420 p = NULL;
421 for (bme = me.bme; NULL != bme; bme = bme->next) 421 for (bme = me.bme; NULL != bme; bme = bme->next)
422 { 422 {
423 if ((0 == memcmp (key, &bme->key, sizeof (struct GNUNET_PeerIdentity))) && 423 if ((0 == memcmp (key, &bme->key, sizeof (struct GNUNET_ShortHashCode))) &&
424 (value == bme->value)) 424 (value == bme->value))
425 { 425 {
426 if (NULL == p) 426 if (NULL == p)
@@ -448,7 +448,7 @@ GNUNET_CONTAINER_multishortmap_remove (struct GNUNET_CONTAINER_MultiShortmap *ma
448 */ 448 */
449int 449int
450GNUNET_CONTAINER_multishortmap_remove_all (struct GNUNET_CONTAINER_MultiShortmap *map, 450GNUNET_CONTAINER_multishortmap_remove_all (struct GNUNET_CONTAINER_MultiShortmap *map,
451 const struct GNUNET_PeerIdentity *key) 451 const struct GNUNET_ShortHashCode *key)
452{ 452{
453 union MapEntry me; 453 union MapEntry me;
454 unsigned int i; 454 unsigned int i;
@@ -468,7 +468,7 @@ GNUNET_CONTAINER_multishortmap_remove_all (struct GNUNET_CONTAINER_MultiShortmap
468 sme = me.sme; 468 sme = me.sme;
469 while (NULL != sme) 469 while (NULL != sme)
470 { 470 {
471 if (0 == memcmp (key, sme->key, sizeof (struct GNUNET_PeerIdentity))) 471 if (0 == memcmp (key, sme->key, sizeof (struct GNUNET_ShortHashCode)))
472 { 472 {
473 if (NULL == p) 473 if (NULL == p)
474 map->map[i].sme = sme->next; 474 map->map[i].sme = sme->next;
@@ -498,7 +498,7 @@ GNUNET_CONTAINER_multishortmap_remove_all (struct GNUNET_CONTAINER_MultiShortmap
498 bme = me.bme; 498 bme = me.bme;
499 while (NULL != bme) 499 while (NULL != bme)
500 { 500 {
501 if (0 == memcmp (key, &bme->key, sizeof (struct GNUNET_PeerIdentity))) 501 if (0 == memcmp (key, &bme->key, sizeof (struct GNUNET_ShortHashCode)))
502 { 502 {
503 if (NULL == p) 503 if (NULL == p)
504 map->map[i].bme = bme->next; 504 map->map[i].bme = bme->next;
@@ -534,7 +534,7 @@ GNUNET_CONTAINER_multishortmap_remove_all (struct GNUNET_CONTAINER_MultiShortmap
534 */ 534 */
535int 535int
536GNUNET_CONTAINER_multishortmap_contains (const struct GNUNET_CONTAINER_MultiShortmap *map, 536GNUNET_CONTAINER_multishortmap_contains (const struct GNUNET_CONTAINER_MultiShortmap *map,
537 const struct GNUNET_PeerIdentity *key) 537 const struct GNUNET_ShortHashCode *key)
538{ 538{
539 union MapEntry me; 539 union MapEntry me;
540 540
@@ -544,7 +544,7 @@ GNUNET_CONTAINER_multishortmap_contains (const struct GNUNET_CONTAINER_MultiShor
544 struct SmallMapEntry *sme; 544 struct SmallMapEntry *sme;
545 545
546 for (sme = me.sme; NULL != sme; sme = sme->next) 546 for (sme = me.sme; NULL != sme; sme = sme->next)
547 if (0 == memcmp (key, sme->key, sizeof (struct GNUNET_PeerIdentity))) 547 if (0 == memcmp (key, sme->key, sizeof (struct GNUNET_ShortHashCode)))
548 return GNUNET_YES; 548 return GNUNET_YES;
549 } 549 }
550 else 550 else
@@ -552,7 +552,7 @@ GNUNET_CONTAINER_multishortmap_contains (const struct GNUNET_CONTAINER_MultiShor
552 struct BigMapEntry *bme; 552 struct BigMapEntry *bme;
553 553
554 for (bme = me.bme; NULL != bme; bme = bme->next) 554 for (bme = me.bme; NULL != bme; bme = bme->next)
555 if (0 == memcmp (key, &bme->key, sizeof (struct GNUNET_PeerIdentity))) 555 if (0 == memcmp (key, &bme->key, sizeof (struct GNUNET_ShortHashCode)))
556 return GNUNET_YES; 556 return GNUNET_YES;
557 } 557 }
558 return GNUNET_NO; 558 return GNUNET_NO;
@@ -571,7 +571,7 @@ GNUNET_CONTAINER_multishortmap_contains (const struct GNUNET_CONTAINER_MultiShor
571 */ 571 */
572int 572int
573GNUNET_CONTAINER_multishortmap_contains_value (const struct GNUNET_CONTAINER_MultiShortmap *map, 573GNUNET_CONTAINER_multishortmap_contains_value (const struct GNUNET_CONTAINER_MultiShortmap *map,
574 const struct GNUNET_PeerIdentity *key, 574 const struct GNUNET_ShortHashCode *key,
575 const void *value) 575 const void *value)
576{ 576{
577 union MapEntry me; 577 union MapEntry me;
@@ -582,7 +582,7 @@ GNUNET_CONTAINER_multishortmap_contains_value (const struct GNUNET_CONTAINER_Mul
582 struct SmallMapEntry *sme; 582 struct SmallMapEntry *sme;
583 583
584 for (sme = me.sme; NULL != sme; sme = sme->next) 584 for (sme = me.sme; NULL != sme; sme = sme->next)
585 if ( (0 == memcmp (key, sme->key, sizeof (struct GNUNET_PeerIdentity))) && 585 if ( (0 == memcmp (key, sme->key, sizeof (struct GNUNET_ShortHashCode))) &&
586 (sme->value == value) ) 586 (sme->value == value) )
587 return GNUNET_YES; 587 return GNUNET_YES;
588 } 588 }
@@ -591,7 +591,7 @@ GNUNET_CONTAINER_multishortmap_contains_value (const struct GNUNET_CONTAINER_Mul
591 struct BigMapEntry *bme; 591 struct BigMapEntry *bme;
592 592
593 for (bme = me.bme; NULL != bme; bme = bme->next) 593 for (bme = me.bme; NULL != bme; bme = bme->next)
594 if ( (0 == memcmp (key, &bme->key, sizeof (struct GNUNET_PeerIdentity))) && 594 if ( (0 == memcmp (key, &bme->key, sizeof (struct GNUNET_ShortHashCode))) &&
595 (bme->value == value) ) 595 (bme->value == value) )
596 return GNUNET_YES; 596 return GNUNET_YES;
597 } 597 }
@@ -667,7 +667,7 @@ grow (struct GNUNET_CONTAINER_MultiShortmap *map)
667 */ 667 */
668int 668int
669GNUNET_CONTAINER_multishortmap_put (struct GNUNET_CONTAINER_MultiShortmap *map, 669GNUNET_CONTAINER_multishortmap_put (struct GNUNET_CONTAINER_MultiShortmap *map,
670 const struct GNUNET_PeerIdentity *key, 670 const struct GNUNET_ShortHashCode *key,
671 void *value, 671 void *value,
672 enum GNUNET_CONTAINER_MultiHashMapOption opt) 672 enum GNUNET_CONTAINER_MultiHashMapOption opt)
673{ 673{
@@ -684,7 +684,7 @@ GNUNET_CONTAINER_multishortmap_put (struct GNUNET_CONTAINER_MultiShortmap *map,
684 struct SmallMapEntry *sme; 684 struct SmallMapEntry *sme;
685 685
686 for (sme = me.sme; NULL != sme; sme = sme->next) 686 for (sme = me.sme; NULL != sme; sme = sme->next)
687 if (0 == memcmp (key, sme->key, sizeof (struct GNUNET_PeerIdentity))) 687 if (0 == memcmp (key, sme->key, sizeof (struct GNUNET_ShortHashCode)))
688 { 688 {
689 if (opt == GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) 689 if (opt == GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)
690 return GNUNET_SYSERR; 690 return GNUNET_SYSERR;
@@ -697,7 +697,7 @@ GNUNET_CONTAINER_multishortmap_put (struct GNUNET_CONTAINER_MultiShortmap *map,
697 struct BigMapEntry *bme; 697 struct BigMapEntry *bme;
698 698
699 for (bme = me.bme; NULL != bme; bme = bme->next) 699 for (bme = me.bme; NULL != bme; bme = bme->next)
700 if (0 == memcmp (key, &bme->key, sizeof (struct GNUNET_PeerIdentity))) 700 if (0 == memcmp (key, &bme->key, sizeof (struct GNUNET_ShortHashCode)))
701 { 701 {
702 if (opt == GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) 702 if (opt == GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)
703 return GNUNET_SYSERR; 703 return GNUNET_SYSERR;
@@ -748,7 +748,7 @@ GNUNET_CONTAINER_multishortmap_put (struct GNUNET_CONTAINER_MultiShortmap *map,
748 */ 748 */
749int 749int
750GNUNET_CONTAINER_multishortmap_get_multiple (const struct GNUNET_CONTAINER_MultiShortmap *map, 750GNUNET_CONTAINER_multishortmap_get_multiple (const struct GNUNET_CONTAINER_MultiShortmap *map,
751 const struct GNUNET_PeerIdentity *key, 751 const struct GNUNET_ShortHashCode *key,
752 GNUNET_CONTAINER_ShortmapIterator it, 752 GNUNET_CONTAINER_ShortmapIterator it,
753 void *it_cls) 753 void *it_cls)
754{ 754{
@@ -766,7 +766,7 @@ GNUNET_CONTAINER_multishortmap_get_multiple (const struct GNUNET_CONTAINER_Multi
766 while (NULL != (sme = nxt)) 766 while (NULL != (sme = nxt))
767 { 767 {
768 nxt = sme->next; 768 nxt = sme->next;
769 if (0 != memcmp (key, sme->key, sizeof (struct GNUNET_PeerIdentity))) 769 if (0 != memcmp (key, sme->key, sizeof (struct GNUNET_ShortHashCode)))
770 continue; 770 continue;
771 if ((it != NULL) && (GNUNET_OK != it (it_cls, key, sme->value))) 771 if ((it != NULL) && (GNUNET_OK != it (it_cls, key, sme->value)))
772 return GNUNET_SYSERR; 772 return GNUNET_SYSERR;
@@ -782,7 +782,7 @@ GNUNET_CONTAINER_multishortmap_get_multiple (const struct GNUNET_CONTAINER_Multi
782 while (NULL != (bme = nxt)) 782 while (NULL != (bme = nxt))
783 { 783 {
784 nxt = bme->next; 784 nxt = bme->next;
785 if (0 != memcmp (key, &bme->key, sizeof (struct GNUNET_PeerIdentity))) 785 if (0 != memcmp (key, &bme->key, sizeof (struct GNUNET_ShortHashCode)))
786 continue; 786 continue;
787 if ((it != NULL) && (GNUNET_OK != it (it_cls, key, bme->value))) 787 if ((it != NULL) && (GNUNET_OK != it (it_cls, key, bme->value)))
788 return GNUNET_SYSERR; 788 return GNUNET_SYSERR;
@@ -908,7 +908,8 @@ GNUNET_CONTAINER_multishortmap_iterator_create (const struct GNUNET_CONTAINER_Mu
908 */ 908 */
909int 909int
910GNUNET_CONTAINER_multishortmap_iterator_next (struct GNUNET_CONTAINER_MultiShortmapIterator *iter, 910GNUNET_CONTAINER_multishortmap_iterator_next (struct GNUNET_CONTAINER_MultiShortmapIterator *iter,
911 struct GNUNET_PeerIdentity *key, const void **value) 911 struct GNUNET_ShortHashCode *key,
912 const void **value)
912{ 913{
913 /* make sure the map has not been modified */ 914 /* make sure the map has not been modified */
914 GNUNET_assert (iter->modification_counter == iter->map->modification_counter); 915 GNUNET_assert (iter->modification_counter == iter->map->modification_counter);