diff options
author | pst <pst@FreeBSD.org> | 1996-02-27 01:59:15 +0000 |
---|---|---|
committer | pst <pst@FreeBSD.org> | 1996-02-27 01:59:15 +0000 |
commit | c2306789fe98946429af7462a2fd453454034a79 (patch) | |
tree | e6563df097216e3af35d87ac698b2ea9eb3f5f75 /lib/libc/db/btree/bt_overflow.c | |
parent | 5476eae499a3e1c3530620c0ebc3a69ffb2f25ba (diff) | |
download | FreeBSD-src-c2306789fe98946429af7462a2fd453454034a79.zip FreeBSD-src-c2306789fe98946429af7462a2fd453454034a79.tar.gz |
Import updated Berkeley DB into CSRG branch
Diffstat (limited to 'lib/libc/db/btree/bt_overflow.c')
-rw-r--r-- | lib/libc/db/btree/bt_overflow.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/libc/db/btree/bt_overflow.c b/lib/libc/db/btree/bt_overflow.c index 0057a03..b28b8e0 100644 --- a/lib/libc/db/btree/bt_overflow.c +++ b/lib/libc/db/btree/bt_overflow.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1990, 1993 + * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by @@ -35,7 +35,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_overflow.c 8.2 (Berkeley) 2/21/94"; +static char sccsid[] = "@(#)bt_overflow.c 8.5 (Berkeley) 7/16/94"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -69,7 +69,7 @@ static char sccsid[] = "@(#)bt_overflow.c 8.2 (Berkeley) 2/21/94"; * * Parameters: * t: tree - * p: pointer to { pgno_t, size_t } + * p: pointer to { pgno_t, u_int32_t } * buf: storage address * bufsz: storage size * @@ -81,15 +81,16 @@ __ovfl_get(t, p, ssz, buf, bufsz) BTREE *t; void *p; size_t *ssz; - char **buf; + void **buf; size_t *bufsz; { PAGE *h; pgno_t pg; - size_t nb, plen, sz; + size_t nb, plen; + u_int32_t sz; memmove(&pg, p, sizeof(pgno_t)); - memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(size_t)); + memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(u_int32_t)); *ssz = sz; #ifdef DEBUG @@ -98,7 +99,8 @@ __ovfl_get(t, p, ssz, buf, bufsz) #endif /* Make the buffer bigger as necessary. */ if (*bufsz < sz) { - if ((*buf = (char *)realloc(*buf, sz)) == NULL) + *buf = (char *)(*buf == NULL ? malloc(sz) : realloc(*buf, sz)); + if (*buf == NULL) return (RET_ERROR); *bufsz = sz; } @@ -142,7 +144,8 @@ __ovfl_put(t, dbt, pg) PAGE *h, *last; void *p; pgno_t npg; - size_t nb, plen, sz; + size_t nb, plen; + u_int32_t sz; /* * Allocate pages and copy the key/data record into them. Store the @@ -181,7 +184,7 @@ __ovfl_put(t, dbt, pg) * * Parameters: * t: tree - * p: pointer to { pgno_t, size_t } + * p: pointer to { pgno_t, u_int32_t } * * Returns: * RET_ERROR, RET_SUCCESS @@ -193,10 +196,11 @@ __ovfl_delete(t, p) { PAGE *h; pgno_t pg; - size_t plen, sz; + size_t plen; + u_int32_t sz; memmove(&pg, p, sizeof(pgno_t)); - memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(size_t)); + memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(u_int32_t)); #ifdef DEBUG if (pg == P_INVALID || sz == 0) |