fix
[oweals/gnunet.git] / src / util / peer.c
index 2ad4b3d671d82ef71efb5aa37400785e4499aed7..f30c720aa073ad8e97165d8af1a079165bec3103 100644 (file)
 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;
 };
@@ -119,10 +116,11 @@ GNUNET_PEER_intern (const struct GNUNET_PeerIdentity *pid)
   table[ret].id = *pid;
   table[ret].rc = 1;
   table[ret].pid = ret;
-  GNUNET_CONTAINER_multihashmap_put (map,
-                                     &pid->hashPubKey,
-                                     &table[ret],
-                                     GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+  GNUNET_break (GNUNET_OK ==
+               GNUNET_CONTAINER_multihashmap_put (map,
+                                                  &pid->hashPubKey,
+                                                  &table[ret],
+                                                  GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
   return ret;
 }
 
@@ -144,14 +142,17 @@ GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id * ids, unsigned int count)
   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]);
+          GNUNET_break (GNUNET_OK ==
+                       GNUNET_CONTAINER_multihashmap_remove (map,
+                                                             &table[id].id.hashPubKey,
+                                                             &table[id]));
           table[id].pid = free_list_start;
           free_list_start = id;
         }
@@ -176,9 +177,10 @@ GNUNET_PEER_change_rc (GNUNET_PEER_Id id, int delta)
   table[id].rc += delta;
   if (table[id].rc == 0)
     {
-      GNUNET_CONTAINER_multihashmap_remove (map,
-                                            &table[id].id.hashPubKey,
-                                            &table[id]);
+      GNUNET_break (GNUNET_OK ==
+                   GNUNET_CONTAINER_multihashmap_remove (map,
+                                                         &table[id].id.hashPubKey,
+                                                         &table[id]));
       table[id].pid = free_list_start;
       free_list_start = id;
     }