]> err.no Git - varnish/commitdiff
Fix the Parent calculation
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 18 Jul 2006 13:18:50 +0000 (13:18 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 18 Jul 2006 13:18:50 +0000 (13:18 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@493 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/lib/libvarnish/binary_heap.c

index bc0ca99c7217073b1262ead10d0b2e46471a9f8b..05ecaece52e340b143fa6db130461d3ae957dba3 100644 (file)
@@ -33,7 +33,7 @@ struct binheap {
        unsigned                granularity;
 };
 
-#define PARENT(u)      (((u) - 1) / 2)
+#define PARENT(u)      ((u) / 2)
 #define CHILD(u,n)     ((u) * 2 + (n))
 
 /* Implementation ----------------------------------------------------*/
@@ -43,6 +43,7 @@ binheap_update(struct binheap *bh, unsigned u)
 {
        assert(bh->magic == BINHEAP_MAGIC);
        assert(u < bh->next);
+       assert(bh->array[u] != NULL);
        if (bh->update == NULL)
                return;
        bh->update(bh->priv, bh->array[u], u);