aboutsummaryrefslogtreecommitdiff
path: root/src/util/container_multipeermap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/container_multipeermap.c')
-rw-r--r--src/util/container_multipeermap.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/util/container_multipeermap.c b/src/util/container_multipeermap.c
index 54a1d1635..8ec3a2077 100644
--- a/src/util/container_multipeermap.c
+++ b/src/util/container_multipeermap.c
@@ -67,7 +67,7 @@ struct SmallMapEntry
67 * If there is a hash collision, we create a linked list. 67 * If there is a hash collision, we create a linked list.
68 */ 68 */
69 struct SmallMapEntry *next; 69 struct SmallMapEntry *next;
70 70
71 /** 71 /**
72 * Key for the entry. 72 * Key for the entry.
73 */ 73 */
@@ -162,10 +162,10 @@ struct GNUNET_CONTAINER_MultiPeerMapIterator
162 * @param len initial size (map will grow as needed) 162 * @param len initial size (map will grow as needed)
163 * @param do_not_copy_keys GNUNET_NO is always safe and should be used by default; 163 * @param do_not_copy_keys GNUNET_NO is always safe and should be used by default;
164 * GNUNET_YES means that on 'put', the 'key' does not have 164 * GNUNET_YES means that on 'put', the 'key' does not have
165 * to be copied as the destination of the pointer is 165 * to be copied as the destination of the pointer is
166 * guaranteed to be life as long as the value is stored in 166 * guaranteed to be life as long as the value is stored in
167 * the hashmap. This can significantly reduce memory 167 * the hashmap. This can significantly reduce memory
168 * consumption, but of course is also a recipie for 168 * consumption, but of course is also a recipie for
169 * heap corruption if the assumption is not true. Only 169 * heap corruption if the assumption is not true. Only
170 * use this if (1) memory use is important in this case and 170 * use this if (1) memory use is important in this case and
171 * (2) you have triple-checked that the invariant holds 171 * (2) you have triple-checked that the invariant holds
@@ -331,7 +331,7 @@ GNUNET_CONTAINER_multipeermap_iterate (const struct
331 struct SmallMapEntry *sme; 331 struct SmallMapEntry *sme;
332 struct SmallMapEntry *nxt; 332 struct SmallMapEntry *nxt;
333 333
334 nxt = me.sme; 334 nxt = me.sme;
335 while (NULL != (sme = nxt)) 335 while (NULL != (sme = nxt))
336 { 336 {
337 nxt = sme->next; 337 nxt = sme->next;
@@ -348,7 +348,7 @@ GNUNET_CONTAINER_multipeermap_iterate (const struct
348 struct BigMapEntry *bme; 348 struct BigMapEntry *bme;
349 struct BigMapEntry *nxt; 349 struct BigMapEntry *nxt;
350 350
351 nxt = me.bme; 351 nxt = me.bme;
352 while (NULL != (bme = nxt)) 352 while (NULL != (bme = nxt))
353 { 353 {
354 nxt = bme->next; 354 nxt = bme->next;
@@ -379,7 +379,7 @@ GNUNET_CONTAINER_multipeermap_iterate (const struct
379 */ 379 */
380int 380int
381GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap *map, 381GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap *map,
382 const struct GNUNET_PeerIdentity *key, 382 const struct GNUNET_PeerIdentity *key,
383 const void *value) 383 const void *value)
384{ 384{
385 union MapEntry me; 385 union MapEntry me;
@@ -390,7 +390,7 @@ GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap *map,
390 i = idx_of (map, key); 390 i = idx_of (map, key);
391 me = map->map[i]; 391 me = map->map[i];
392 if (map->use_small_entries) 392 if (map->use_small_entries)
393 { 393 {
394 struct SmallMapEntry *sme; 394 struct SmallMapEntry *sme;
395 struct SmallMapEntry *p; 395 struct SmallMapEntry *p;
396 396
@@ -459,7 +459,7 @@ GNUNET_CONTAINER_multipeermap_remove_all (struct GNUNET_CONTAINER_MultiPeerMap
459 i = idx_of (map, key); 459 i = idx_of (map, key);
460 me = map->map[i]; 460 me = map->map[i];
461 if (map->use_small_entries) 461 if (map->use_small_entries)
462 { 462 {
463 struct SmallMapEntry *sme; 463 struct SmallMapEntry *sme;
464 struct SmallMapEntry *p; 464 struct SmallMapEntry *p;
465 465
@@ -668,7 +668,7 @@ grow (struct GNUNET_CONTAINER_MultiPeerMap *map)
668 */ 668 */
669int 669int
670GNUNET_CONTAINER_multipeermap_put (struct GNUNET_CONTAINER_MultiPeerMap *map, 670GNUNET_CONTAINER_multipeermap_put (struct GNUNET_CONTAINER_MultiPeerMap *map,
671 const struct GNUNET_PeerIdentity *key, 671 const struct GNUNET_PeerIdentity *key,
672 void *value, 672 void *value,
673 enum GNUNET_CONTAINER_MultiHashMapOption opt) 673 enum GNUNET_CONTAINER_MultiHashMapOption opt)
674{ 674{
@@ -684,7 +684,7 @@ GNUNET_CONTAINER_multipeermap_put (struct GNUNET_CONTAINER_MultiPeerMap *map,
684 { 684 {
685 struct SmallMapEntry *sme; 685 struct SmallMapEntry *sme;
686 686
687 for (sme = me.sme; NULL != sme; sme = sme->next) 687 for (sme = me.sme; NULL != sme; sme = sme->next)
688 if (0 == memcmp (key, sme->key, sizeof (struct GNUNET_PeerIdentity))) 688 if (0 == memcmp (key, sme->key, sizeof (struct GNUNET_PeerIdentity)))
689 { 689 {
690 if (opt == GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) 690 if (opt == GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)
@@ -697,7 +697,7 @@ GNUNET_CONTAINER_multipeermap_put (struct GNUNET_CONTAINER_MultiPeerMap *map,
697 { 697 {
698 struct BigMapEntry *bme; 698 struct BigMapEntry *bme;
699 699
700 for (bme = me.bme; NULL != bme; bme = bme->next) 700 for (bme = me.bme; NULL != bme; bme = bme->next)
701 if (0 == memcmp (key, &bme->key, sizeof (struct GNUNET_PeerIdentity))) 701 if (0 == memcmp (key, &bme->key, sizeof (struct GNUNET_PeerIdentity)))
702 { 702 {
703 if (opt == GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) 703 if (opt == GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)
@@ -715,7 +715,7 @@ GNUNET_CONTAINER_multipeermap_put (struct GNUNET_CONTAINER_MultiPeerMap *map,
715 if (map->use_small_entries) 715 if (map->use_small_entries)
716 { 716 {
717 struct SmallMapEntry *sme; 717 struct SmallMapEntry *sme;
718 718
719 sme = GNUNET_new (struct SmallMapEntry); 719 sme = GNUNET_new (struct SmallMapEntry);
720 sme->key = key; 720 sme->key = key;
721 sme->value = value; 721 sme->value = value;
@@ -725,7 +725,7 @@ GNUNET_CONTAINER_multipeermap_put (struct GNUNET_CONTAINER_MultiPeerMap *map,
725 else 725 else
726 { 726 {
727 struct BigMapEntry *bme; 727 struct BigMapEntry *bme;
728 728
729 bme = GNUNET_new (struct BigMapEntry); 729 bme = GNUNET_new (struct BigMapEntry);
730 bme->key = *key; 730 bme->key = *key;
731 bme->value = value; 731 bme->value = value;
@@ -760,9 +760,9 @@ GNUNET_CONTAINER_multipeermap_get_multiple (const struct GNUNET_CONTAINER_MultiP
760 me = map->map[idx_of (map, key)]; 760 me = map->map[idx_of (map, key)];
761 if (map->use_small_entries) 761 if (map->use_small_entries)
762 { 762 {
763 struct SmallMapEntry *sme; 763 struct SmallMapEntry *sme;
764 struct SmallMapEntry *nxt; 764 struct SmallMapEntry *nxt;
765 765
766 nxt = me.sme; 766 nxt = me.sme;
767 while (NULL != (sme = nxt)) 767 while (NULL != (sme = nxt))
768 { 768 {
@@ -776,9 +776,9 @@ GNUNET_CONTAINER_multipeermap_get_multiple (const struct GNUNET_CONTAINER_MultiP
776 } 776 }
777 else 777 else
778 { 778 {
779 struct BigMapEntry *bme; 779 struct BigMapEntry *bme;
780 struct BigMapEntry *nxt; 780 struct BigMapEntry *nxt;
781 781
782 nxt = me.bme; 782 nxt = me.bme;
783 while (NULL != (bme = nxt)) 783 while (NULL != (bme = nxt))
784 { 784 {