/*
This file is part of GNUnet.
(C) 2008, 2009 Christian Grothoff (and other contributing authors)
-
+
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your
option) any later version.
-
+
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
#include "platform.h"
#include "gnunet_util_lib.h"
+#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
-#define DEBUG 0
+#define EXTRA_CHECKS 0
/**
* Node in the heap.
};
-#if DEBUG
+#if EXTRA_CHECKS
/**
* Check if internal invariants hold for the given node.
*
heap->root = root->left_child;
insert_node (heap, heap->root, root->right_child);
}
+ if (heap->walk_pos == root)
+ heap->walk_pos = heap->root;
GNUNET_free (root);
-#if DEBUG
+#if EXTRA_CHECKS
GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
(heap->size == heap->root->tree_size + 1));
CHECK (heap->root);
/**
* Removes a node from the heap.
- *
+ *
* @param node node to remove
* @return element data stored at the node
*/
if (heap->walk_pos == node)
heap->walk_pos = NULL;
GNUNET_free (node);
-#if DEBUG
+#if EXTRA_CHECKS
CHECK (heap->root);
GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
(heap->size == heap->root->tree_size + 1));
struct GNUNET_CONTAINER_HeapNode *node,
GNUNET_CONTAINER_HeapCostType new_cost)
{
-#if DEBUG
+#if EXTRA_CHECKS
GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
(heap->size == heap->root->tree_size + 1));
CHECK (heap->root);
#endif
remove_node (node);
-#if DEBUG
+#if EXTRA_CHECKS
CHECK (heap->root);
GNUNET_assert (((heap->size == 1) && (heap->root == NULL)) ||
(heap->size == heap->root->tree_size + 2));
heap->root = node;
else
insert_node (heap, heap->root, node);
-#if DEBUG
+#if EXTRA_CHECKS
CHECK (heap->root);
GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
(heap->size == heap->root->tree_size + 1));