You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jw...@apache.org on 2002/08/14 01:47:51 UTC
cvs commit: httpd-2.0/modules/experimental cache_pqueue.c cache_pqueue.h
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) <q->size &&(q->pri(q->d[pos]) < q->pri(q->d[left(pos)]))) ||
+ (right(pos)<q->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