+void bt_latchaudit (BtDb *bt)
+{
+ushort idx, hashidx;
+BtPageSet set[1];
+
+#ifdef unix
+ for( idx = 1; idx < bt->mgr->latchmgr->latchdeployed; idx++ ) {
+ set->latch = bt->mgr->latchsets + idx;
+ if( set->latch->pin ) {
+ fprintf(stderr, "latchset %d pinned for page %.6x\n", idx, set->latch->page_no);
+ set->latch->pin = 0;
+ }
+ }
+
+ for( hashidx = 0; hashidx < bt->mgr->latchmgr->latchhash; hashidx++ ) {
+ if( idx = bt->mgr->latchmgr->table[hashidx].slot ) do {
+ set->latch = bt->mgr->latchsets + idx;
+ if( set->latch->hash != hashidx )
+ fprintf(stderr, "latchset %d wrong hashidx\n", idx);
+ if( set->latch->pin )
+ fprintf(stderr, "latchset %d pinned for page %.8x\n", idx, set->latch->page_no);
+ } while( idx = set->latch->next );
+ }
+
+ set->page_no = bt_getid(bt->mgr->latchmgr->alloc[1].right);
+
+ while( set->page_no ) {
+ fprintf(stderr, "free: %.6x\n", (uint)set->page_no);
+
+ if( set->pool = bt_pinpool (bt, set->page_no) )
+ set->page = bt_page (bt, set->pool, set->page_no);
+ else
+ return;
+
+ set->page_no = bt_getid(set->page->right);
+ bt_unpinpool (set->pool);
+ }
+#endif
+}
+