1 /*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #if defined(LIBC_SCCS) && !defined(lint) 9 static char sccsid[] = "@(#)rec_utils.c 5.2 (Berkeley) 09/11/91"; 10 #endif /* LIBC_SCCS and not lint */ 11 12 #include <sys/param.h> 13 #include <db.h> 14 #include <stdio.h> 15 #include <stdlib.h> 16 #include <string.h> 17 #include "recno.h" 18 19 /* 20 * __REC_RET -- Build return data as a result of search or scan. 21 * 22 * Parameters: 23 * t: tree 24 * d: LEAF to be returned to the user. 25 * data: user's data structure 26 * 27 * Returns: 28 * RET_SUCCESS, RET_ERROR. 29 */ 30 int 31 __rec_ret(t, e, data) 32 BTREE *t; 33 EPG *e; 34 DBT *data; 35 { 36 register RLEAF *rl; 37 register char *p; 38 39 rl = GETRLEAF(e->page, e->index); 40 if (rl->flags & P_BIGDATA) { 41 if (__ovfl_get(t, rl->bytes, 42 &data->size, &t->bt_dbuf, &t->bt_dbufsz)) 43 return (RET_ERROR); 44 } else { 45 if (rl->dsize > t->bt_dbufsz) { 46 if ((p = realloc(t->bt_dbuf, rl->dsize)) == NULL) 47 return (RET_ERROR); 48 t->bt_dbuf = p; 49 t->bt_dbufsz = rl->dsize; 50 } 51 bcopy(rl->bytes, t->bt_dbuf, t->bt_dbufsz); 52 data->size = rl->dsize; 53 } 54 data->data = t->bt_dbuf; 55 56 return (RET_SUCCESS); 57 } 58