]> mj.ucw.cz Git - libucw.git/commitdiff
Fix bug in traversing of empty heap.
authorMartin Mares <mj@ucw.cz>
Wed, 18 Jun 2003 18:28:55 +0000 (18:28 +0000)
committerMartin Mares <mj@ucw.cz>
Wed, 18 Jun 2003 18:28:55 +0000 (18:28 +0000)
lib/binheap.h

index e6f7afda7954c29cd5eedf96d6132952745e325f..74820c00107285c7c92e4fc6c73f03ea83be85b1 100644 (file)
@@ -177,8 +177,9 @@ BH_PREFIX(init)(BH_HEAP *heap)
 #define BH_FOR_ALL(bh_px, bh_heap, bh_var)     \
 do {                                           \
   struct bh_node *bh_stack[32];                        \
-  bh_stack[0] = (bh_heap)->root.first_son;     \
-  uns bh_sp = 1;                               \
+  uns bh_sp = 0;                               \
+  if (bh_stack[0] = (bh_heap)->root.first_son)  \
+    bh_sp++;                                   \
   while (bh_sp) {                              \
     struct bh_node *bh_var = bh_stack[--bh_sp];        \
     if (bh_var->next_sibling)                  \