diff options
Diffstat (limited to 'lib/libc/db/hash/hash_buf.c')
-rw-r--r-- | lib/libc/db/hash/hash_buf.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/libc/db/hash/hash_buf.c b/lib/libc/db/hash/hash_buf.c index 7eadbb9..8741ea5 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> @@ -169,18 +170,12 @@ newbuf(HTAB *hashp, u_int32_t addr, BUFHEAD *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); } -#ifdef PURIFY - memset(bp->page, 0xff, hashp->BSIZE); -#endif if (hashp->nbufs) hashp->nbufs--; } else { @@ -319,8 +314,10 @@ __buf_free(HTAB *hashp, int do_free, int 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; |