/* See if there's anything in the free DB */
MDB_cursor m2;
MDB_node *leaf;
- ULONG *kptr, oldest;
+ txnid_t *kptr, oldest;
- m2.mc_txn = txn;
- m2.mc_dbi = FREE_DBI;
- m2.mc_snum = 0;
- m2.mc_flags = 0;
+ mdb_cursor_init(&m2, txn, FREE_DBI);
mdb_search_page(&m2, NULL, 0);
leaf = NODEPTR(m2.mc_pg[m2.mc_top], 0);
- kptr = (ULONG *)NODEKEY(leaf);
+ kptr = (txnid_t *)NODEKEY(leaf);
{
unsigned int i;
if (!txn->mt_u.dirty_list[0].mid)
goto done;
- DPRINTF("committing txn %lu %p on mdbenv %p, root page %lu",
- txn->mt_txnid, txn, (void *)env, txn->mt_dbs[MAIN_DBI].md_root);
+ DPRINTF("committing txn %zu %p on mdbenv %p, root page %zu",
+ txn->mt_txnid, (void *)txn, (void *)env, txn->mt_dbs[MAIN_DBI].md_root);
- mc.mc_txn = txn;
- mc.mc_dbi = FREE_DBI;
- mc.mc_flags = 0;
+ mdb_cursor_init(&mc, txn, FREE_DBI);
/* should only be one record now */
if (env->me_pghead) {
static int
cursor_push_page(MDB_cursor *mc, MDB_page *mp)
{
- DPRINTF("pushing page %lu on db %u cursor %p", mp->mp_pgno,
+ DPRINTF("pushing page %zu on db %u cursor %p", mp->mp_pgno,
mc->mc_dbi, (void *) mc);
- if (mc->mc_snum >= CURSOR_STACK)
+ if (mc->mc_snum >= CURSOR_STACK) {
+ assert(mc->mc_snum < CURSOR_STACK);
return ENOMEM;
+ }
mc->mc_top = mc->mc_snum++;
mc->mc_pg[mc->mc_top] = mp;
if (mc->mc_snum < 2) {
return MDB_NOTFOUND; /* root has no siblings */
}
- ptop = mc->mc_top-1;
- DPRINTF("parent page is page %lu, index %u",
+ cursor_pop_page(mc);
- mc->mc_pg[ptop]->mp_pgno, mc->mc_ki[ptop]);
+ DPRINTF("parent page is page %zu, index %u",
+ mc->mc_pg[mc->mc_top]->mp_pgno, mc->mc_ki[mc->mc_top]);
- cursor_pop_page(mc);
- if (move_right ? (mc->mc_ki[ptop] + 1u >= NUMKEYS(mc->mc_pg[ptop]))
- : (mc->mc_ki[ptop] == 0)) {
+ if (move_right ? (mc->mc_ki[mc->mc_top] + 1u >= NUMKEYS(mc->mc_pg[mc->mc_top]))
+ : (mc->mc_ki[mc->mc_top] == 0)) {
DPRINTF("no more keys left, moving to %s sibling",
move_right ? "right" : "left");
if ((rc = mdb_sibling(mc, move_right)) != MDB_SUCCESS)