Return-Path: Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 86348 invoked by uid 500); 13 Aug 2002 23:47:52 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 86337 invoked by uid 500); 13 Aug 2002 23:47:52 -0000 Delivered-To: apmail-httpd-2.0-cvs@apache.org Date: 13 Aug 2002 23:47:51 -0000 Message-ID: <20020813234751.47002.qmail@icarus.apache.org> From: jwoolley@apache.org To: httpd-2.0-cvs@apache.org Subject: cvs commit: httpd-2.0/modules/experimental cache_pqueue.c cache_pqueue.h X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N jwoolley 2002/08/13 16:47:50 Modified: modules/experimental cache_pqueue.c cache_pqueue.h Log: add some debugging code -- verifies that the heap property is satisfied Revision Changes Path 1.7 +16 -0 httpd-2.0/modules/experimental/cache_pqueue.c Index: cache_pqueue.c =================================================================== RCS file: /home/cvs/httpd-2.0/modules/experimental/cache_pqueue.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -u -r1.6 -r1.7 --- cache_pqueue.c 17 Jul 2002 14:52:36 -0000 1.6 +++ cache_pqueue.c 13 Aug 2002 23:47:50 -0000 1.7 @@ -336,3 +336,19 @@ } cache_pq_free(dup); } + +static int cache_pq_subtree_is_valid(cache_pqueue_t *q, int pos) +{ + if ((left(pos) size &&(q->pri(q->d[pos]) < q->pri(q->d[left(pos)]))) || + (right(pos)size &&(q->pri(q->d[pos]) < q->pri(q->d[right(pos)])))) + { + return 0; + } + return ((left(pos)>=q->size ||(cache_pq_subtree_is_valid(q, left(pos)))) && + (right(pos)>=q->size||(cache_pq_subtree_is_valid(q, right(pos))))); +} + +int cache_pq_is_valid(cache_pqueue_t *q) +{ + return cache_pq_subtree_is_valid(q, 1); +} 1.3 +8 -0 httpd-2.0/modules/experimental/cache_pqueue.h Index: cache_pqueue.h =================================================================== RCS file: /home/cvs/httpd-2.0/modules/experimental/cache_pqueue.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -u -r1.2 -r1.3 --- cache_pqueue.h 16 Jul 2002 23:58:56 -0000 1.2 +++ cache_pqueue.h 13 Aug 2002 23:47:50 -0000 1.3 @@ -187,6 +187,14 @@ FILE *out, cache_pqueue_print_entry print); +/** + * checks that the pq is in the right order, etc + * @internal + * debug function only + * @param q the queue + */ +int cache_pq_is_valid(cache_pqueue_t *q); + #ifdef __cplusplus } #endif