From: phk Date: Tue, 18 Jul 2006 13:18:50 +0000 (+0000) Subject: Fix the Parent calculation X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9929cdd1203d2295b53d51ac434b0e5efc160951;p=varnish Fix the Parent calculation git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@493 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/lib/libvarnish/binary_heap.c b/varnish-cache/lib/libvarnish/binary_heap.c index bc0ca99c..05ecaece 100644 --- a/varnish-cache/lib/libvarnish/binary_heap.c +++ b/varnish-cache/lib/libvarnish/binary_heap.c @@ -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);