150995Sbostic /*- 250995Sbostic * Copyright (c) 1990 The Regents of the University of California. 350995Sbostic * All rights reserved. 450995Sbostic * 550995Sbostic * %sccs.include.redist.c% 650995Sbostic */ 750995Sbostic 850995Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*51093Sbostic static char sccsid[] = "@(#)rec_utils.c 5.2 (Berkeley) 09/11/91"; 1050995Sbostic #endif /* LIBC_SCCS and not lint */ 1150995Sbostic 1250995Sbostic #include <sys/param.h> 1350995Sbostic #include <db.h> 1450995Sbostic #include <stdio.h> 1550995Sbostic #include <stdlib.h> 1650995Sbostic #include <string.h> 17*51093Sbostic #include "recno.h" 1850995Sbostic 1950995Sbostic /* 2050995Sbostic * __REC_RET -- Build return data as a result of search or scan. 2150995Sbostic * 2250995Sbostic * Parameters: 2350995Sbostic * t: tree 2450995Sbostic * d: LEAF to be returned to the user. 2550995Sbostic * data: user's data structure 2650995Sbostic * 2750995Sbostic * Returns: 2850995Sbostic * RET_SUCCESS, RET_ERROR. 2950995Sbostic */ 3050995Sbostic int 3150995Sbostic __rec_ret(t, e, data) 3250995Sbostic BTREE *t; 3350995Sbostic EPG *e; 3450995Sbostic DBT *data; 3550995Sbostic { 3650995Sbostic register RLEAF *rl; 37*51093Sbostic register char *p; 3850995Sbostic 3950995Sbostic rl = GETRLEAF(e->page, e->index); 4050995Sbostic if (rl->flags & P_BIGDATA) { 4150995Sbostic if (__ovfl_get(t, rl->bytes, 4250995Sbostic &data->size, &t->bt_dbuf, &t->bt_dbufsz)) 4350995Sbostic return (RET_ERROR); 4450995Sbostic } else { 4550995Sbostic if (rl->dsize > t->bt_dbufsz) { 46*51093Sbostic if ((p = realloc(t->bt_dbuf, rl->dsize)) == NULL) 4750995Sbostic return (RET_ERROR); 48*51093Sbostic t->bt_dbuf = p; 4950995Sbostic t->bt_dbufsz = rl->dsize; 5050995Sbostic } 5150995Sbostic bcopy(rl->bytes, t->bt_dbuf, t->bt_dbufsz); 5250995Sbostic data->size = rl->dsize; 5350995Sbostic } 5450995Sbostic data->data = t->bt_dbuf; 5550995Sbostic 5650995Sbostic return (RET_SUCCESS); 5750995Sbostic } 58