summaryrefslogtreecommitdiffstats
path: root/lib/libc/db/btree/bt_overflow.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/db/btree/bt_overflow.c')
-rw-r--r--lib/libc/db/btree/bt_overflow.c26
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)
OpenPOWER on IntegriCloud