struct PeerEntry
{
/**
- * the identifier itself
+ * The identifier itself
*/
struct GNUNET_PeerIdentity id;
/**
- * Short version of the identifier;
- * if the RC==0, then index of next
- * free slot in table, otherwise
- * equal to this slot in the table.
+ * Short version of the identifier; if the RC==0, then index of next
+ * free slot in table, otherwise equal to this slot in the table.
*/
GNUNET_PEER_Id pid;
/**
- * Reference counter, 0 if this slot
- * is not used.
+ * Reference counter, 0 if this slot is not used.
*/
unsigned int rc;
};
* @return the interned identity.
*/
GNUNET_PEER_Id
-GNUNET_PEER_intern (const struct GNUNET_PeerIdentity * pid)
+GNUNET_PEER_intern (const struct GNUNET_PeerIdentity *pid)
{
GNUNET_PEER_Id ret;
struct PeerEntry *e;
return 0;
if (NULL == map)
map = GNUNET_CONTAINER_multihashmap_create (32);
- e = GNUNET_CONTAINER_multihashmap_get (map,
- &pid->hashPubKey);
+ e = GNUNET_CONTAINER_multihashmap_get (map, &pid->hashPubKey);
if (e != NULL)
{
GNUNET_assert (e->rc > 0);
if (ret == size)
{
GNUNET_array_grow (table, size, size + 16);
- for (i=ret;i<size;i++)
- table[i].pid = i + 1;
+ for (i = ret; i < size; i++)
+ table[i].pid = i + 1;
}
if (ret == 0)
{
table[ret].rc = 1;
table[ret].pid = ret;
GNUNET_CONTAINER_multihashmap_put (map,
- &pid->hashPubKey,
- &table[ret],
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+ &pid->hashPubKey,
+ &table[ret],
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
return ret;
}
* @param count size of the ids array
*/
void
-GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id * ids,
- unsigned int count)
+GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id * ids, unsigned int count)
{
int i;
GNUNET_PEER_Id id;
for (i = count - 1; i >= 0; i--)
{
id = ids[i];
+ if (id == 0)
+ continue;
GNUNET_assert (id < size);
GNUNET_assert (table[id].rc > 0);
table[id].rc--;
if (table[id].rc == 0)
- {
- GNUNET_CONTAINER_multihashmap_remove (map,
- &table[id].id.hashPubKey,
- &table[id]);
- table[id].pid = free_list_start;
- free_list_start = id;
- }
+ {
+ GNUNET_CONTAINER_multihashmap_remove (map,
+ &table[id].id.hashPubKey,
+ &table[id]);
+ table[id].pid = free_list_start;
+ free_list_start = id;
+ }
}
}
if (table[id].rc == 0)
{
GNUNET_CONTAINER_multihashmap_remove (map,
- &table[id].id.hashPubKey,
- &table[id]);
+ &table[id].id.hashPubKey,
+ &table[id]);
table[id].pid = free_list_start;
free_list_start = id;
}
* @param pid where to write the normal peer identity
*/
void
-GNUNET_PEER_resolve (GNUNET_PEER_Id id,
- struct GNUNET_PeerIdentity * pid)
+GNUNET_PEER_resolve (GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
{
if (id == 0)
{