gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r9416 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r9416 - gnunet/src/util
Date: Sun, 8 Nov 2009 06:23:16 -0700

Author: grothoff
Date: 2009-11-08 06:23:16 -0700 (Sun, 08 Nov 2009)
New Revision: 9416

Modified:
   gnunet/src/util/container_heap.c
Log:
fixing leak

Modified: gnunet/src/util/container_heap.c
===================================================================
--- gnunet/src/util/container_heap.c    2009-11-08 12:03:30 UTC (rev 9415)
+++ gnunet/src/util/container_heap.c    2009-11-08 13:23:16 UTC (rev 9416)
@@ -132,7 +132,6 @@
   while (heap->size > 0)
     GNUNET_CONTAINER_heap_remove_root (heap);
   GNUNET_free (heap);
-  return;
 }
 
 static struct GNUNET_CONTAINER_heap_node *
@@ -393,16 +392,22 @@
   struct GNUNET_CONTAINER_heap_node *root_node;
   struct GNUNET_CONTAINER_heap_node *last;
 
-  if ((root == NULL) || (root->size == 0) || (root->root == NULL))
-    return NULL;
+  if ( (root == NULL) || 
+       (root->size == 0) || 
+       (root->root == NULL) )
+    {
+      GNUNET_break (0);
+      return NULL;
+    }
 
   root_node = root->root;
   ret = root_node->element;
   last = getPos (root, root->size);
 
-  if ((root_node == last) && (root->size == 1))
+  if ( (root_node == last) && (root->size == 1))
     {
       /* We are removing the last node in the heap! */
+      GNUNET_free (last);
       root->root = NULL;
       root->traversal_pos = NULL;
       GNUNET_assert (0 == --root->size);
@@ -418,10 +423,7 @@
   root_node->cost = last->cost;
 
   if (root->traversal_pos == last)
-    {
-      root->traversal_pos = root->root;
-    }
-
+    root->traversal_pos = root->root;   
   GNUNET_free (last);
   root->size--;
   percolateDownHeap (root->root, root);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]