37 #if defined(LIBC_SCCS) && !defined(lint)
38 static char sccsid[] =
"@(#)bt_overflow.c 8.5 (Berkeley) 7/16/94";
41 #include <sys/param.h>
47 #include "../include/db.h"
80 __ovfl_get(t, p, ssz, buf, bufsz)
92 memmove(&pg, p,
sizeof(pgno_t));
93 memmove(&sz, (
char *)p +
sizeof(pgno_t),
sizeof(u_int32_t));
97 if (pg == P_INVALID || sz == 0)
102 *buf = (
char *)(*buf == NULL ? malloc(sz) : realloc(*buf, sz));
112 plen = t->bt_psize - BTDATAOFF;
113 for (p = *buf;; p = (
char *)p + nb, pg = h->nextpg) {
114 if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
118 memmove(p, (
char *)h + BTDATAOFF, nb);
119 mpool_put(t->bt_mp, h, 0);
124 return (RET_SUCCESS);
139 __ovfl_put(t, dbt, pg)
154 plen = t->bt_psize - BTDATAOFF;
155 for (last = NULL, p = dbt->data, sz = dbt->size;;
156 p = (
char *)p + plen, last = h) {
157 if ((h = __bt_new(t, &npg)) == NULL)
161 h->nextpg = h->prevpg = P_INVALID;
162 h->flags = P_OVERFLOW;
163 h->lower = h->upper = 0;
166 memmove((
char *)h + BTDATAOFF, p, nb);
169 last->nextpg = h->pgno;
170 mpool_put(t->bt_mp, last, MPOOL_DIRTY);
174 if ((sz -= nb) == 0) {
175 mpool_put(t->bt_mp, h, MPOOL_DIRTY);
179 return (RET_SUCCESS);
202 memmove(&pg, p,
sizeof(pgno_t));
203 memmove(&sz, (
char *)p +
sizeof(pgno_t),
sizeof(u_int32_t));
206 if (pg == P_INVALID || sz == 0)
209 if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
213 if (h->flags & P_PRESERVE) {
214 mpool_put(t->bt_mp, h, 0);
215 return (RET_SUCCESS);
219 for (plen = t->bt_psize - BTDATAOFF;; sz -= plen) {
224 if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
227 return (RET_SUCCESS);