ret = __db_ret(dbp, cp->page, indx, &dbt, &t->bt_rkey.data, &t->bt_rkey.ulen);
if ((ret = __db_ret(dbp, cp->page, indx, &dbt, &t->bt_rkey.data, &t->bt_rkey.ulen)) != 0) goto err; arg = &dbt; } else arg = key;
__bam_c_put(dbc, key, data, flags)	DBC *dbc;	DBT *key, *data;	int flags;{	BTREE *t;	CURSOR *cp, copy;	DB *dbp;	DBT dbt;	db_indx_t indx;	db_pgno_t pgno;	int exact, needkey, ret;	void *arg;	DEBUG_LWRITE(dbc->dbp, dbc->txn, "bam_c_put",	    flags == DB_KEYFIRST || flags == DB_KEYLAST ? key : NULL,	    data, flags);	cp = dbc->internal;	if ((ret = __db_cputchk(dbc->dbp, key, data, flags,	    F_ISSET(dbc->dbp, DB_AM_RDONLY), cp->pgno != PGNO_INVALID)) != 0)		return (ret);	GETHANDLE(dbc->dbp, dbc->txn, &dbp, ret);	t = dbp->internal;	/* Initialize the cursor for a new retrieval. */	copy = *cp;	cp->page = NULL;	cp->lock = LOCK_INVALID;	/*	 * To split, we need a valid key for the page.  Since it's a cursor,	 * we have to build one.	 */	if (0) {split:		if (needkey) {			memset(&dbt, 0, sizeof(DBT));			ret = __db_ret(dbp, cp->page, indx,			    &dbt, &t->bt_rkey.data, &t->bt_rkey.ulen);			DISCARD(dbp, cp);			if (ret)				goto err;			arg = &dbt;		} else {			(void)__bam_stkrel(dbp);			arg = key;		}		if ((ret = __bam_split(dbp, arg)) != 0)			goto err;	}	/* If there's no key supplied, use the cursor. */	if (flags == DB_KEYFIRST || flags == DB_KEYLAST)		needkey = 0;	else {		needkey = 1;		if (cp->dpgno == PGNO_INVALID) {			pgno = cp->pgno;			indx = cp->indx;		} else {			pgno = cp->dpgno;			indx = cp->dindx;		}		/* Acquire the current page. */		if ((ret = __bam_lget(dbp,		    0, cp->pgno, DB_LOCK_WRITE, &cp->lock)) != 0)			goto err;		if ((ret = __bam_pget(dbp, &cp->page, &pgno, 0)) != 0)			goto err;	}	ret = 0;	switch (flags) {	case DB_AFTER:	case DB_BEFORE:	case DB_CURRENT:		if ((ret = __bam_iitem(dbp, &cp->page,		    &indx, key, data, flags, 0)) == DB_NEEDSPLIT)			goto split;		break;	case DB_KEYFIRST:		exact = 0;		if ((ret =		    __bam_c_search(dbp, cp, key, S_KEYFIRST, 0, &exact)) != 0)			goto err;		indx = cp->dpgno == PGNO_INVALID ? cp->indx : cp->dindx;		if ((ret = __bam_iitem(dbp, &cp->page, &indx, key,		    data, DB_BEFORE, exact ? 0 : BI_NEWKEY)) == DB_NEEDSPLIT)			goto split;		if (ret)			goto err;		break;	case DB_KEYLAST:		exact = 0;		if ((ret =		    __bam_c_search(dbp, cp, key, S_KEYLAST, 0, &exact)) != 0)			goto err;		indx = cp->dpgno == PGNO_INVALID ? cp->indx : cp->dindx;		if ((ret = __bam_iitem(dbp, &cp->page, &indx, key,		    data, DB_AFTER, exact ? 0 : BI_NEWKEY)) == DB_NEEDSPLIT)			goto split;		break;	}	if (ret)		goto err;	/*	 * Update the cursor to point to the new entry.  The new entry was	 * stored on the current page, because we split pages until it was	 * possible.	 */	if (cp->dpgno == PGNO_INVALID)		cp->indx = indx;	else		cp->dindx = indx;	/*	 * If the previous cursor record has been deleted, delete it.  The	 * returned key isn't a deleted key, so clear the flag.	 */	if (F_ISSET(&copy, C_DELETED) &&	    (ret = __bam_c_physdel(dbp, &copy, cp->page)) != 0)		goto err;	F_CLR(cp, C_DELETED | C_REPLACE);	/* Release the previous lock, if any. */	if (copy.lock != LOCK_INVALID)		(void)__BT_TLPUT(dbp, copy.lock);	/* Discard the pinned page. */	ret = memp_fput(dbp->mpf, cp->page, 0);	if (0) {err:		if (cp->page != NULL)			(void)memp_fput(dbp->mpf, cp->page, 0);		if (cp->lock != LOCK_INVALID)			(void)__BT_TLPUT(dbp, cp->lock);		*cp = copy;	}	PUTHANDLE(dbp);	return (ret);}