summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2007-08-07 05:40:35 +0000
committerRay Lai <ray@cvs.openbsd.org>2007-08-07 05:40:35 +0000
commite9a829aea6a0bf6b9da2c5f72407bf80c083b71f (patch)
tree9bec68389f65fcdc6f1e60d7a0122b96c6d6673b /lib
parent2d5b677a9e990c57ed21b7fe0b972373d7258107 (diff)
Let realloc handle NULL pointers, plus a spacing fix.
OK millert and moritz.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/db/recno/rec_utils.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/libc/db/recno/rec_utils.c b/lib/libc/db/recno/rec_utils.c
index 7e1f44be38f..488531ea49f 100644
--- a/lib/libc/db/recno/rec_utils.c
+++ b/lib/libc/db/recno/rec_utils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rec_utils.c,v 1.7 2005/08/05 13:03:00 espie Exp $ */
+/* $OpenBSD: rec_utils.c,v 1.8 2007/08/07 05:40:34 ray Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -46,7 +46,7 @@
* e: key/data pair to be returned
* nrec: record number
* key: user's key structure
- * data: user's data structure
+ * data: user's data structure
*
* Returns:
* RET_SUCCESS, RET_ERROR.
@@ -62,9 +62,7 @@ __rec_ret(BTREE *t, EPG *e, recno_t nrec, DBT *key, DBT *data)
/* We have to copy the key, it's not on the page. */
if (sizeof(recno_t) > t->bt_rkey.size) {
- p = (void *)(t->bt_rkey.data == NULL ?
- malloc(sizeof(recno_t)) :
- realloc(t->bt_rkey.data, sizeof(recno_t)));
+ p = realloc(t->bt_rkey.data, sizeof(recno_t));
if (p == NULL)
return (RET_ERROR);
t->bt_rkey.data = p;
@@ -92,9 +90,7 @@ dataonly:
} else if (F_ISSET(t, B_DB_LOCK)) {
/* Use +1 in case the first record retrieved is 0 length. */
if (rl->dsize + 1 > t->bt_rdata.size) {
- p = (void *)(t->bt_rdata.data == NULL ?
- malloc(rl->dsize + 1) :
- realloc(t->bt_rdata.data, rl->dsize + 1));
+ p = realloc(t->bt_rdata.data, rl->dsize + 1);
if (p == NULL)
return (RET_ERROR);
t->bt_rdata.data = p;