diff options
author | Colin Percival <cperciva@FreeBSD.org> | 2009-04-22 14:07:14 +0000 |
---|---|---|
committer | Colin Percival <cperciva@FreeBSD.org> | 2009-04-22 14:07:14 +0000 |
commit | 57895cdc764809ad29336431ee6b43c68fe15f15 (patch) | |
tree | ee06066b1e128e876793d149c7f3c844851f69a8 /lib/libc | |
parent | cff0c03ef7b93d6ab09a8ce2ab009348e5c7aecd (diff) |
Notes
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/db/btree/bt_split.c | 2 | ||||
-rw-r--r-- | lib/libc/db/hash/hash_buf.c | 9 | ||||
-rw-r--r-- | lib/libc/db/mpool/mpool.c | 2 |
3 files changed, 8 insertions, 5 deletions
diff --git a/lib/libc/db/btree/bt_split.c b/lib/libc/db/btree/bt_split.c index dc2791762af01..94fa15317d8f6 100644 --- a/lib/libc/db/btree/bt_split.c +++ b/lib/libc/db/btree/bt_split.c @@ -381,7 +381,7 @@ bt_page(t, h, lp, rp, skip, ilen) } /* Put the new left page for the split into place. */ - if ((l = (PAGE *)malloc(t->bt_psize)) == NULL) { + if ((l = (PAGE *)calloc(1, t->bt_psize)) == NULL) { mpool_put(t->bt_mp, r, 0); return (NULL); } diff --git a/lib/libc/db/hash/hash_buf.c b/lib/libc/db/hash/hash_buf.c index db8ad1a3db247..0882eb315a49c 100644 --- a/lib/libc/db/hash/hash_buf.c +++ b/lib/libc/db/hash/hash_buf.c @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include <stddef.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #ifdef DEBUG #include <assert.h> @@ -174,12 +175,12 @@ newbuf(hashp, addr, prev_bp) */ if (hashp->nbufs || (bp->flags & BUF_PIN)) { /* Allocate a new one */ - if ((bp = (BUFHEAD *)malloc(sizeof(BUFHEAD))) == NULL) + if ((bp = (BUFHEAD *)calloc(1, sizeof(BUFHEAD))) == NULL) return (NULL); #ifdef PURIFY memset(bp, 0xff, sizeof(BUFHEAD)); #endif - if ((bp->page = (char *)malloc(hashp->BSIZE)) == NULL) { + if ((bp->page = (char *)calloc(1, hashp->BSIZE)) == NULL) { free(bp); return (NULL); } @@ -328,8 +329,10 @@ __buf_free(hashp, do_free, to_disk) } /* Check if we are freeing stuff */ if (do_free) { - if (bp->page) + if (bp->page) { + (void)memset(bp->page, 0, hashp->BSIZE); free(bp->page); + } BUF_REMOVE(bp); free(bp); bp = LRU; diff --git a/lib/libc/db/mpool/mpool.c b/lib/libc/db/mpool/mpool.c index aedf1fd0115f7..24860b2043bd9 100644 --- a/lib/libc/db/mpool/mpool.c +++ b/lib/libc/db/mpool/mpool.c @@ -343,7 +343,7 @@ mpool_bkt(mp) return (bp); } -new: if ((bp = (BKT *)malloc(sizeof(BKT) + mp->pagesize)) == NULL) +new: if ((bp = (BKT *)calloc(1, sizeof(BKT) + mp->pagesize)) == NULL) return (NULL); #ifdef STATISTICS ++mp->pagealloc; |