diff --git a/lib/libc/db/btree/bt_overflow.c b/lib/libc/db/btree/bt_overflow.c index e618c8c9d3d8..266d59990cac 100644 --- a/lib/libc/db/btree/bt_overflow.c +++ b/lib/libc/db/btree/bt_overflow.c @@ -92,7 +92,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) { - *buf = (char *)(*buf == NULL ? malloc(sz) : reallocf(*buf, sz)); + *buf = reallocf(*buf, sz); if (*buf == NULL) return (RET_ERROR); *bufsz = sz; diff --git a/lib/libc/db/btree/bt_utils.c b/lib/libc/db/btree/bt_utils.c index 77ab916e531e..92b76baa30f4 100644 --- a/lib/libc/db/btree/bt_utils.c +++ b/lib/libc/db/btree/bt_utils.c @@ -84,8 +84,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; @@ -111,9 +110,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; diff --git a/lib/libc/db/recno/rec_get.c b/lib/libc/db/recno/rec_get.c index df85b16a5900..b543d478b8f0 100644 --- a/lib/libc/db/recno/rec_get.c +++ b/lib/libc/db/recno/rec_get.c @@ -122,9 +122,7 @@ __rec_fpipe(BTREE *t, recno_t top) u_char *p; if (t->bt_rdata.size < t->bt_reclen) { - t->bt_rdata.data = t->bt_rdata.data == NULL ? - malloc(t->bt_reclen) : - reallocf(t->bt_rdata.data, t->bt_reclen); + t->bt_rdata.data = reallocf(t->bt_rdata.data, t->bt_reclen); if (t->bt_rdata.data == NULL) return (RET_ERROR); t->bt_rdata.size = t->bt_reclen; @@ -193,9 +191,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); - t->bt_rdata.data = t->bt_rdata.data == NULL ? - malloc(t->bt_rdata.size) : - reallocf(t->bt_rdata.data, t->bt_rdata.size); + t->bt_rdata.data = reallocf(t->bt_rdata.data, t->bt_rdata.size); if (t->bt_rdata.data == NULL) return (RET_ERROR); p = (u_char *)t->bt_rdata.data + len; @@ -230,9 +226,7 @@ __rec_fmap(BTREE *t, recno_t top) size_t len; if (t->bt_rdata.size < t->bt_reclen) { - t->bt_rdata.data = t->bt_rdata.data == NULL ? - malloc(t->bt_reclen) : - reallocf(t->bt_rdata.data, t->bt_reclen); + t->bt_rdata.data = reallocf(t->bt_rdata.data, t->bt_reclen); if (t->bt_rdata.data == NULL) return (RET_ERROR); t->bt_rdata.size = t->bt_reclen; diff --git a/lib/libc/db/recno/rec_utils.c b/lib/libc/db/recno/rec_utils.c index 0294d9533ad4..39285a545a51 100644 --- a/lib/libc/db/recno/rec_utils.c +++ b/lib/libc/db/recno/rec_utils.c @@ -67,9 +67,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; @@ -97,9 +95,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;