summaryrefslogtreecommitdiff
path: root/lib/libc/db
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2007-08-08 23:57:20 +0000
committerRay Lai <ray@cvs.openbsd.org>2007-08-08 23:57:20 +0000
commitf54a42394d9456bba0085be379068c51fba89444 (patch)
treeca7d454a92644268fb6f019022366d57c5a3d715 /lib/libc/db
parent80caedb98d88aa8dadbe239dfbc83e151eeba5e5 (diff)
Let realloc handle NULL. Initial diff from Charles Longeau.
OK millert and jaredy.
Diffstat (limited to 'lib/libc/db')
-rw-r--r--lib/libc/db/btree/bt_overflow.c4
-rw-r--r--lib/libc/db/btree/bt_utils.c9
2 files changed, 5 insertions, 8 deletions
diff --git a/lib/libc/db/btree/bt_overflow.c b/lib/libc/db/btree/bt_overflow.c
index 1867073b4e0..c9c411f97cf 100644
--- a/lib/libc/db/btree/bt_overflow.c
+++ b/lib/libc/db/btree/bt_overflow.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bt_overflow.c,v 1.9 2005/08/05 13:02:59 espie Exp $ */
+/* $OpenBSD: bt_overflow.c,v 1.10 2007/08/08 23:57:19 ray Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -89,7 +89,7 @@ __ovfl_get(BTREE *t, void *p, size_t *ssz, void **buf, size_t *bufsz)
#endif
/* Make the buffer bigger as necessary. */
if (*bufsz < sz) {
- tp = (char *)(*buf == NULL ? malloc(sz) : realloc(*buf, sz));
+ tp = realloc(*buf, sz);
if (tp == NULL)
return (RET_ERROR);
*buf = tp;
diff --git a/lib/libc/db/btree/bt_utils.c b/lib/libc/db/btree/bt_utils.c
index 9d404ec5a1a..19a63db3441 100644
--- a/lib/libc/db/btree/bt_utils.c
+++ b/lib/libc/db/btree/bt_utils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bt_utils.c,v 1.9 2005/08/05 13:03:00 espie Exp $ */
+/* $OpenBSD: bt_utils.c,v 1.10 2007/08/08 23:57:19 ray Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -80,8 +80,7 @@ __bt_ret(BTREE *t, EPG *e, DBT *key, DBT *rkey, DBT *data, DBT *rdata, int copy)
key->data = rkey->data;
} else if (copy || F_ISSET(t, B_DB_LOCK)) {
if (bl->ksize > rkey->size) {
- p = (void *)(rkey->data == NULL ?
- malloc(bl->ksize) : realloc(rkey->data, bl->ksize));
+ p = realloc(rkey->data, bl->ksize);
if (p == NULL)
return (RET_ERROR);
rkey->data = p;
@@ -107,9 +106,7 @@ dataonly:
} else if (copy || F_ISSET(t, B_DB_LOCK)) {
/* Use +1 in case the first record retrieved is 0 length. */
if (bl->dsize + 1 > rdata->size) {
- p = (void *)(rdata->data == NULL ?
- malloc(bl->dsize + 1) :
- realloc(rdata->data, bl->dsize + 1));
+ p = realloc(rdata->data, bl->dsize + 1);
if (p == NULL)
return (RET_ERROR);
rdata->data = p;