gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r8919 - GNUnet/src/util/containers


From: gnunet
Subject: [GNUnet-SVN] r8919 - GNUnet/src/util/containers
Date: Mon, 31 Aug 2009 16:03:10 -0600

Author: nevans
Date: 2009-08-31 16:03:08 -0600 (Mon, 31 Aug 2009)
New Revision: 8919

Modified:
   GNUnet/src/util/containers/heap.c
Log:
null checks

Modified: GNUnet/src/util/containers/heap.c
===================================================================
--- GNUnet/src/util/containers/heap.c   2009-08-31 22:02:33 UTC (rev 8918)
+++ GNUnet/src/util/containers/heap.c   2009-08-31 22:03:08 UTC (rev 8919)
@@ -112,6 +112,8 @@
 {
   struct GNUNET_CONTAINER_Heap *heap;
   heap = malloc (sizeof (struct GNUNET_CONTAINER_Heap));
+  if (heap == NULL)
+    return heap;
   heap->max_size = -1;
   heap->type = type;
   heap->root = NULL;
@@ -144,12 +146,12 @@
       ret = node;
     }
 
-  if ((ret == NULL) && (node->left_child != NULL))
+  if ((ret == NULL) && (node != NULL) && (node->left_child != NULL))
     {
       ret = find_element (node->left_child, element);
     }
 
-  if ((ret == NULL) && (node->right_child != NULL))
+  if ((ret == NULL) && (node != NULL) && (node->right_child != NULL))
     {
       ret = find_element (node->right_child, element);
     }
@@ -415,13 +417,15 @@
   struct GNUNET_CONTAINER_heap_node *root_node;
   struct GNUNET_CONTAINER_heap_node *last;
 
+  if (root == NULL)
+    return NULL;
+  if ((root->size == 0) || (root_node == NULL))
+    return NULL;
+
   root_node = root->root;
   ret = root_node->element;
   last = getPos (root, root->size);
 
-  if ((root->size == 0) || (root_node == NULL))
-    return NULL;
-
   if ((root_node == last) && (root->size == 1)) /* We are removing the last 
node in the heap! */
     {
       root->root = NULL;





reply via email to

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