summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2007-08-08 07:16:51 +0000
committerRay Lai <ray@cvs.openbsd.org>2007-08-08 07:16:51 +0000
commit93f0a93ea70527771e250436883680a24a846799 (patch)
tree5aeda8b8648b70ec208162e9601871ca1987c296
parentab7d8d6f72eaf545669a7d736154cba05a99d173 (diff)
realloc can handle NULL values. From Charles Longeau.
OK jaredy.
-rw-r--r--lib/libc/db/recno/rec_get.c14
-rw-r--r--lib/libc/db/recno/rec_put.c6
2 files changed, 6 insertions, 14 deletions
diff --git a/lib/libc/db/recno/rec_get.c b/lib/libc/db/recno/rec_get.c
index 98995bb0089..87ac76f077c 100644
--- a/lib/libc/db/recno/rec_get.c
+++ b/lib/libc/db/recno/rec_get.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rec_get.c,v 1.10 2005/08/05 13:03:00 espie Exp $ */
+/* $OpenBSD: rec_get.c,v 1.11 2007/08/08 07:16:50 ray Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -119,9 +119,7 @@ __rec_fpipe(BTREE *t, recno_t top)
void *tp;
if (t->bt_rdata.size < t->bt_reclen) {
- tp = t->bt_rdata.data == NULL ?
- malloc(t->bt_reclen) :
- realloc(t->bt_rdata.data, t->bt_reclen);
+ tp = realloc(t->bt_rdata.data, t->bt_reclen);
if (tp == NULL)
return (RET_ERROR);
t->bt_rdata.data = tp;
@@ -192,9 +190,7 @@ __rec_vpipe(BTREE *t, recno_t top)
if (sz == 0) {
len = p - (u_char *)t->bt_rdata.data;
t->bt_rdata.size += (sz = 256);
- tp = t->bt_rdata.data == NULL ?
- malloc(t->bt_rdata.size) :
- realloc(t->bt_rdata.data, t->bt_rdata.size);
+ tp = realloc(t->bt_rdata.data, t->bt_rdata.size);
if (tp == NULL)
return (RET_ERROR);
t->bt_rdata.data = tp;
@@ -231,9 +227,7 @@ __rec_fmap(BTREE *t, recno_t top)
void *tp;
if (t->bt_rdata.size < t->bt_reclen) {
- tp = t->bt_rdata.data == NULL ?
- malloc(t->bt_reclen) :
- realloc(t->bt_rdata.data, t->bt_reclen);
+ tp = realloc(t->bt_rdata.data, t->bt_reclen);
if (tp == NULL)
return (RET_ERROR);
t->bt_rdata.data = tp;
diff --git a/lib/libc/db/recno/rec_put.c b/lib/libc/db/recno/rec_put.c
index 708db159e1f..2440927a53f 100644
--- a/lib/libc/db/recno/rec_put.c
+++ b/lib/libc/db/recno/rec_put.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rec_put.c,v 1.10 2005/08/05 13:03:00 espie Exp $ */
+/* $OpenBSD: rec_put.c,v 1.11 2007/08/08 07:16:50 ray Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -79,9 +79,7 @@ __rec_put(const DB *dbp, DBT *key, const DBT *data, u_int flags)
goto einval;
if (t->bt_rdata.size < t->bt_reclen) {
- tp = t->bt_rdata.data == NULL ?
- malloc(t->bt_reclen) :
- realloc(t->bt_rdata.data, t->bt_reclen);
+ tp = realloc(t->bt_rdata.data, t->bt_reclen);
if (tp == NULL)
return (RET_ERROR);
t->bt_rdata.data = tp;