From 9929cdd1203d2295b53d51ac434b0e5efc160951 Mon Sep 17 00:00:00 2001 From: phk Date: Tue, 18 Jul 2006 13:18:50 +0000 Subject: [PATCH] Fix the Parent calculation git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@493 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/lib/libvarnish/binary_heap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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); -- 2.39.5