From f07c1a056211f61ee3987b2fc2186b7da38f1f55 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 18 Jun 2003 18:28:55 +0000 Subject: [PATCH] Fix bug in traversing of empty heap. --- lib/binheap.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/binheap.h b/lib/binheap.h index e6f7afda..74820c00 100644 --- a/lib/binheap.h +++ b/lib/binheap.h @@ -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) \ -- 2.39.2