aboutsummaryrefslogtreecommitdiff
path: root/src/util/peer.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-11-01 20:47:52 +0000
committerChristian Grothoff <christian@grothoff.org>2009-11-01 20:47:52 +0000
commit652e89b59ed2207c2c12172fdabcd6e659995c81 (patch)
treef054c819d483c1056e18c1099afd4c7fcd2582a0 /src/util/peer.c
parent5e4113e83368849500792e57946c3d8dd9e548d8 (diff)
downloadgnunet-652e89b59ed2207c2c12172fdabcd6e659995c81.tar.gz
gnunet-652e89b59ed2207c2c12172fdabcd6e659995c81.zip
fixing bio testcase and a bug in bio.c, also indenting
Diffstat (limited to 'src/util/peer.c')
-rw-r--r--src/util/peer.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/util/peer.c b/src/util/peer.c
index acb1b3922..2ad4b3d67 100644
--- a/src/util/peer.c
+++ b/src/util/peer.c
@@ -83,7 +83,7 @@ static unsigned int free_list_start;
83 * @return the interned identity. 83 * @return the interned identity.
84 */ 84 */
85GNUNET_PEER_Id 85GNUNET_PEER_Id
86GNUNET_PEER_intern (const struct GNUNET_PeerIdentity * pid) 86GNUNET_PEER_intern (const struct GNUNET_PeerIdentity *pid)
87{ 87{
88 GNUNET_PEER_Id ret; 88 GNUNET_PEER_Id ret;
89 struct PeerEntry *e; 89 struct PeerEntry *e;
@@ -93,8 +93,7 @@ GNUNET_PEER_intern (const struct GNUNET_PeerIdentity * pid)
93 return 0; 93 return 0;
94 if (NULL == map) 94 if (NULL == map)
95 map = GNUNET_CONTAINER_multihashmap_create (32); 95 map = GNUNET_CONTAINER_multihashmap_create (32);
96 e = GNUNET_CONTAINER_multihashmap_get (map, 96 e = GNUNET_CONTAINER_multihashmap_get (map, &pid->hashPubKey);
97 &pid->hashPubKey);
98 if (e != NULL) 97 if (e != NULL)
99 { 98 {
100 GNUNET_assert (e->rc > 0); 99 GNUNET_assert (e->rc > 0);
@@ -105,8 +104,8 @@ GNUNET_PEER_intern (const struct GNUNET_PeerIdentity * pid)
105 if (ret == size) 104 if (ret == size)
106 { 105 {
107 GNUNET_array_grow (table, size, size + 16); 106 GNUNET_array_grow (table, size, size + 16);
108 for (i=ret;i<size;i++) 107 for (i = ret; i < size; i++)
109 table[i].pid = i + 1; 108 table[i].pid = i + 1;
110 } 109 }
111 if (ret == 0) 110 if (ret == 0)
112 { 111 {
@@ -121,9 +120,9 @@ GNUNET_PEER_intern (const struct GNUNET_PeerIdentity * pid)
121 table[ret].rc = 1; 120 table[ret].rc = 1;
122 table[ret].pid = ret; 121 table[ret].pid = ret;
123 GNUNET_CONTAINER_multihashmap_put (map, 122 GNUNET_CONTAINER_multihashmap_put (map,
124 &pid->hashPubKey, 123 &pid->hashPubKey,
125 &table[ret], 124 &table[ret],
126 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 125 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
127 return ret; 126 return ret;
128} 127}
129 128
@@ -135,8 +134,7 @@ GNUNET_PEER_intern (const struct GNUNET_PeerIdentity * pid)
135 * @param count size of the ids array 134 * @param count size of the ids array
136 */ 135 */
137void 136void
138GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id * ids, 137GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id * ids, unsigned int count)
139 unsigned int count)
140{ 138{
141 int i; 139 int i;
142 GNUNET_PEER_Id id; 140 GNUNET_PEER_Id id;
@@ -150,13 +148,13 @@ GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id * ids,
150 GNUNET_assert (table[id].rc > 0); 148 GNUNET_assert (table[id].rc > 0);
151 table[id].rc--; 149 table[id].rc--;
152 if (table[id].rc == 0) 150 if (table[id].rc == 0)
153 { 151 {
154 GNUNET_CONTAINER_multihashmap_remove (map, 152 GNUNET_CONTAINER_multihashmap_remove (map,
155 &table[id].id.hashPubKey, 153 &table[id].id.hashPubKey,
156 &table[id]); 154 &table[id]);
157 table[id].pid = free_list_start; 155 table[id].pid = free_list_start;
158 free_list_start = id; 156 free_list_start = id;
159 } 157 }
160 } 158 }
161} 159}
162 160
@@ -179,8 +177,8 @@ GNUNET_PEER_change_rc (GNUNET_PEER_Id id, int delta)
179 if (table[id].rc == 0) 177 if (table[id].rc == 0)
180 { 178 {
181 GNUNET_CONTAINER_multihashmap_remove (map, 179 GNUNET_CONTAINER_multihashmap_remove (map,
182 &table[id].id.hashPubKey, 180 &table[id].id.hashPubKey,
183 &table[id]); 181 &table[id]);
184 table[id].pid = free_list_start; 182 table[id].pid = free_list_start;
185 free_list_start = id; 183 free_list_start = id;
186 } 184 }
@@ -194,8 +192,7 @@ GNUNET_PEER_change_rc (GNUNET_PEER_Id id, int delta)
194 * @param pid where to write the normal peer identity 192 * @param pid where to write the normal peer identity
195 */ 193 */
196void 194void
197GNUNET_PEER_resolve (GNUNET_PEER_Id id, 195GNUNET_PEER_resolve (GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
198 struct GNUNET_PeerIdentity * pid)
199{ 196{
200 if (id == 0) 197 if (id == 0)
201 { 198 {