summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorray <ray@openbsd.org>2007-08-07 05:40:34 +0000
committerray <ray@openbsd.org>2007-08-07 05:40:34 +0000
commitf2a81f4078663c405ae7b709bbd84e9dec662571 (patch)
tree83b41e4d299bf03a11be47a8e4c2ab0f2ec8a31d /lib/libc
parent A few changes to deal with multi-user performance issues seen. this (diff)
downloadwireguard-openbsd-f2a81f4078663c405ae7b709bbd84e9dec662571.tar.xz
wireguard-openbsd-f2a81f4078663c405ae7b709bbd84e9dec662571.zip
Let realloc handle NULL pointers, plus a spacing fix.
OK millert and moritz.
Diffstat (limited to 'lib/libc')
-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;