- BTSTACK *new;
-
- if ((new = (BTSTACK *) malloc((unsigned) sizeof(BTSTACK)))
- == (BTSTACK *) NULL)
- return (RET_ERROR);
- new->bts_pgno = pgno;
- new->bts_next = t->bt_stack;
- t->bt_stack = new;
-
- return (RET_SUCCESS);
-}
-
-pgno_t
-_bt_pop(t)
- BTREE_P t;
-{
- BTSTACK *s;
- pgno_t p = P_NONE;
-
- if ((s = t->bt_stack) != (BTSTACK *) NULL) {
- p = s->bts_pgno;
- t->bt_stack = s->bts_next;
- (void) free ((char *) s);
- }
- return (p);
-}
-
-#ifdef DEBUG
-void
-_btdump(tree)
- BTREE tree;
-{
- BTREE_P t = (BTREE_P) tree;
- DATUM *d;
- IDATUM *id;
- BTHEADER *h;
- pgno_t npages;
- pgno_t i;
- index_t cur, top;
-
- npages = t->bt_npages;
- (void) printf("\"%s\" fd %d pgsz %d curpg %d @ 0x%lx",
- t->bt_fname, t->bt_s.bt_d.d_fd,
- t->bt_psize, t->bt_curpage);
- (void) printf("npg %d cmp 0x%lx flags=(", npages, t->bt_compare);
- if (t->bt_flags & BTF_SEQINIT)
- (void) printf("BTF_SEQINIT");
- (void) printf(")\n");
-
- for (i = P_ROOT; i <= npages; i++) {
- if (_bt_getpage(t, i) == RET_ERROR)
- _punt();
- h = t->bt_curpage;
- top = NEXTINDEX(h);
- (void) printf(" page %d:\n", i);
- (void) printf("\tpgno %d prev %d next %d\n",
- h->h_pgno, h->h_prevpg, h->h_nextpg);
- (void) printf("\tlower %d upper %d nextind %d flags (",
- h->h_lower, h->h_upper, top);
- if (h->h_flags & F_LEAF)
- (void) printf("F_LEAF");
- else
- (void) printf("<internal>");
- if (h->h_flags & F_DIRTY)
- (void) printf("|F_DIRTY");
- if (h->h_flags & F_PRESERVE)
- (void) printf("|F_PRESERVE");
- if (h->h_flags & F_CONT) {
- (void) printf("|F_CONT)");
- if (h->h_prevpg == P_NONE) {
- size_t longsz;
- (void) bcopy((char *) &(h->h_linp[0]),
- (char *) &longsz,
- sizeof(longsz));
- printf("\n\t\t(chain start, data length %ld)",
- longsz);
- }
- printf("\n");
- continue;
- }
- (void) printf(")\n");
- for (cur = 0; cur < top; cur++) {
- (void) printf("\t [%d] off %d ", cur, h->h_linp[cur]);
- if (h->h_flags & F_LEAF) {
- d = (DATUM *) GETDATUM(h,cur);
- (void) printf("ksize %d", d->d_ksize);
- if (d->d_flags & D_BIGKEY)
- (void) printf(" (indirect)");
- (void) printf("; dsize %d", d->d_dsize);
- if (d->d_flags & D_BIGDATA)
- (void) printf(" (indirect)");
- } else {
- id = (IDATUM *) GETDATUM(h,cur);
- (void) printf("size %d pgno %d",
- id->i_size, id->i_pgno);
- if (id->i_flags & D_BIGKEY)
- (void) printf(" (indirect)");
- }
- (void) printf("\n");
- }
- (void) printf("\n");
- }