summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2009-04-11 15:19:26 +0000
committerXin LI <delphij@FreeBSD.org>2009-04-11 15:19:26 +0000
commita0b7611fb83c6a67e4e957cf933c8a2917480c33 (patch)
tree00e0f5b1c6be80e79c1581cdc61c49b086810a42 /lib/libc
parentfc29423f5ff08dffd1e6cc30d2c0e7abdda6619e (diff)
Notes
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/db/README8
-rw-r--r--lib/libc/db/btree/bt_open.c6
-rw-r--r--lib/libc/db/btree/bt_split.c5
-rw-r--r--lib/libc/db/hash/hash_buf.c15
-rw-r--r--lib/libc/db/mpool/mpool.c5
5 files changed, 11 insertions, 28 deletions
diff --git a/lib/libc/db/README b/lib/libc/db/README
index bed2c92fa51f..1f9ae7240658 100644
--- a/lib/libc/db/README
+++ b/lib/libc/db/README
@@ -1,4 +1,5 @@
# @(#)README 8.27 (Berkeley) 9/1/94
+# $FreeBSD$
This is version 1.85 of the Berkeley DB code.
@@ -31,10 +32,3 @@ mpool The memory pool routines.
recno The fixed/variable length record routines.
test Test package.
-============================================
-Debugging:
-
-If you're running a memory checker (e.g. Purify) on DB, make sure that
-you recompile it with "-DPURIFY" in the CFLAGS, first. By default,
-allocated pages are not initialized by the DB code, and they will show
-up as reads of uninitialized memory in the buffer write routines.
diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c
index 92ac140bc5b9..be43ce5e83b5 100644
--- a/lib/libc/db/btree/bt_open.c
+++ b/lib/libc/db/btree/bt_open.c
@@ -159,9 +159,8 @@ __bt_open(fname, flags, mode, openinfo, dflags)
goto einval;
/* Allocate and initialize DB and BTREE structures. */
- if ((t = (BTREE *)malloc(sizeof(BTREE))) == NULL)
+ if ((t = (BTREE *)calloc(1, sizeof(BTREE))) == NULL)
goto err;
- memset(t, 0, sizeof(BTREE));
t->bt_fd = -1; /* Don't close unopened fd on error. */
t->bt_lorder = b.lorder;
t->bt_order = NOT;
@@ -169,9 +168,8 @@ __bt_open(fname, flags, mode, openinfo, dflags)
t->bt_pfx = b.prefix;
t->bt_rfd = -1;
- if ((t->bt_dbp = dbp = (DB *)malloc(sizeof(DB))) == NULL)
+ if ((t->bt_dbp = dbp = (DB *)calloc(1, sizeof(DB))) == NULL)
goto err;
- memset(t->bt_dbp, 0, sizeof(DB));
if (t->bt_lorder != machine_lorder)
F_SET(t, B_NEEDSWAP);
diff --git a/lib/libc/db/btree/bt_split.c b/lib/libc/db/btree/bt_split.c
index dc2791762af0..60165db057ce 100644
--- a/lib/libc/db/btree/bt_split.c
+++ b/lib/libc/db/btree/bt_split.c
@@ -381,13 +381,10 @@ 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);
}
-#ifdef PURIFY
- memset(l, 0xff, t->bt_psize);
-#endif
l->pgno = h->pgno;
l->nextpg = r->pgno;
l->prevpg = h->prevpg;
diff --git a/lib/libc/db/hash/hash_buf.c b/lib/libc/db/hash/hash_buf.c
index db8ad1a3db24..a0e8d382d3eb 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,18 +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);
}
-#ifdef PURIFY
- memset(bp->page, 0xff, hashp->BSIZE);
-#endif
if (hashp->nbufs)
hashp->nbufs--;
} else {
@@ -328,8 +323,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 aedf1fd0115f..c95d71f42b3a 100644
--- a/lib/libc/db/mpool/mpool.c
+++ b/lib/libc/db/mpool/mpool.c
@@ -343,14 +343,11 @@ 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;
#endif
-#if defined(DEBUG) || defined(PURIFY)
- memset(bp, 0xff, sizeof(BKT) + mp->pagesize);
-#endif
bp->page = (char *)bp + sizeof(BKT);
++mp->curcache;
return (bp);