/*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * * %sccs.include.redist.c% */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)rec_utils.c 5.2 (Berkeley) 09/11/91"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include #include #include "recno.h" /* * __REC_RET -- Build return data as a result of search or scan. * * Parameters: * t: tree * d: LEAF to be returned to the user. * data: user's data structure * * Returns: * RET_SUCCESS, RET_ERROR. */ int __rec_ret(t, e, data) BTREE *t; EPG *e; DBT *data; { register RLEAF *rl; register char *p; rl = GETRLEAF(e->page, e->index); if (rl->flags & P_BIGDATA) { if (__ovfl_get(t, rl->bytes, &data->size, &t->bt_dbuf, &t->bt_dbufsz)) return (RET_ERROR); } else { if (rl->dsize > t->bt_dbufsz) { if ((p = realloc(t->bt_dbuf, rl->dsize)) == NULL) return (RET_ERROR); t->bt_dbuf = p; t->bt_dbufsz = rl->dsize; } bcopy(rl->bytes, t->bt_dbuf, t->bt_dbufsz); data->size = rl->dsize; } data->data = t->bt_dbuf; return (RET_SUCCESS); }