aboutsummaryrefslogtreecommitdiff
path: root/src/util/container_heap.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-11-01 20:47:52 +0000
committerChristian Grothoff <christian@grothoff.org>2009-11-01 20:47:52 +0000
commit652e89b59ed2207c2c12172fdabcd6e659995c81 (patch)
treef054c819d483c1056e18c1099afd4c7fcd2582a0 /src/util/container_heap.c
parent5e4113e83368849500792e57946c3d8dd9e548d8 (diff)
downloadgnunet-652e89b59ed2207c2c12172fdabcd6e659995c81.tar.gz
gnunet-652e89b59ed2207c2c12172fdabcd6e659995c81.zip
fixing bio testcase and a bug in bio.c, also indenting
Diffstat (limited to 'src/util/container_heap.c')
-rw-r--r--src/util/container_heap.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/util/container_heap.c b/src/util/container_heap.c
index 4709d97a6..9d252159f 100644
--- a/src/util/container_heap.c
+++ b/src/util/container_heap.c
@@ -67,7 +67,8 @@ struct GNUNET_CONTAINER_Heap
67 * @param heap the heap 67 * @param heap the heap
68 * @return NULL if the heap is empty 68 * @return NULL if the heap is empty
69 */ 69 */
70void *GNUNET_CONTAINER_heap_peek (struct GNUNET_CONTAINER_Heap *heap) 70void *
71GNUNET_CONTAINER_heap_peek (struct GNUNET_CONTAINER_Heap *heap)
71{ 72{
72 if ((heap == NULL) || (heap->root == NULL)) 73 if ((heap == NULL) || (heap->root == NULL))
73 return NULL; 74 return NULL;
@@ -76,7 +77,7 @@ void *GNUNET_CONTAINER_heap_peek (struct GNUNET_CONTAINER_Heap *heap)
76} 77}
77 78
78static int 79static int
79next_power_of_2(int v) 80next_power_of_2 (int v)
80{ 81{
81 v |= v >> 1; 82 v |= v >> 1;
82 v |= v >> 2; 83 v |= v >> 2;
@@ -129,7 +130,7 @@ void
129GNUNET_CONTAINER_heap_destroy (struct GNUNET_CONTAINER_Heap *heap) 130GNUNET_CONTAINER_heap_destroy (struct GNUNET_CONTAINER_Heap *heap)
130{ 131{
131 while (heap->size > 0) 132 while (heap->size > 0)
132 GNUNET_CONTAINER_heap_remove_root (heap); 133 GNUNET_CONTAINER_heap_remove_root (heap);
133 GNUNET_free (heap); 134 GNUNET_free (heap);
134 return; 135 return;
135} 136}
@@ -175,7 +176,7 @@ getNextPos (struct GNUNET_CONTAINER_Heap *root)
175 else 176 else
176 { 177 {
177 parent = root->root; 178 parent = root->root;
178 for (i = next_power_of_2(pos) >> 2; i > 1; i >>= 1) 179 for (i = next_power_of_2 (pos) >> 2; i > 1; i >>= 1)
179 { 180 {
180 if (((pos / i) % 2) == 0) 181 if (((pos / i) % 2) == 0)
181 parent = parent->left_child; 182 parent = parent->left_child;
@@ -209,7 +210,7 @@ getPos (struct GNUNET_CONTAINER_Heap *root, unsigned int pos)
209 else 210 else
210 { 211 {
211 ret = root->root; 212 ret = root->root;
212 for (i = next_power_of_2(pos) >> 2; i > 0; i >>= 1) 213 for (i = next_power_of_2 (pos) >> 2; i > 0; i >>= 1)
213 { 214 {
214 if (((pos / i) % 2) == 0) 215 if (((pos / i) % 2) == 0)
215 ret = ret->left_child; 216 ret = ret->left_child;