Loading...
db/mpool/FreeBSD/mpool.c Libc-763.13 Libc-594.9.4
--- Libc/Libc-763.13/db/mpool/FreeBSD/mpool.c
+++ Libc/Libc-594.9.4/db/mpool/FreeBSD/mpool.c
@@ -10,6 +10,10 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
@@ -31,7 +35,7 @@
 static char sccsid[] = "@(#)mpool.c	8.5 (Berkeley) 7/26/94";
 #endif /* LIBC_SCCS and not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/db/mpool/mpool.c,v 1.16 2009/03/28 04:00:46 delphij Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/db/mpool/mpool.c,v 1.12 2004/09/10 05:41:41 kuriyama Exp $");
 
 #include "namespace.h"
 #include <sys/param.h>
@@ -58,9 +62,11 @@
  * mpool_open --
  *	Initialize a memory pool.
  */
-/* ARGSUSED */
 MPOOL *
-mpool_open(void *key, int fd, pgno_t pagesize, pgno_t maxcache)
+mpool_open(key, fd, pagesize, maxcache)
+	void *key;
+	int fd;
+	pgno_t pagesize, maxcache;
 {
 	struct stat sb;
 	MPOOL *mp;
@@ -97,8 +103,11 @@
  *	Initialize input/output filters.
  */
 void
-mpool_filter(MPOOL *mp, void (*pgin) (void *, pgno_t, void *),
-    void (*pgout) (void *, pgno_t, void *), void *pgcookie)
+mpool_filter(mp, pgin, pgout, pgcookie)
+	MPOOL *mp;
+	void (*pgin)(void *, pgno_t, void *);
+	void (*pgout)(void *, pgno_t, void *);
+	void *pgcookie;
 {
 	mp->pgin = pgin;
 	mp->pgout = pgout;
@@ -144,10 +153,11 @@
  * mpool_get
  *	Get a page.
  */
-/* ARGSUSED */
 void *
-mpool_get(MPOOL *mp, pgno_t pgno,
-    u_int flags)		/* XXX not used? */
+mpool_get(mp, pgno, flags)
+	MPOOL *mp;
+	pgno_t pgno;
+	u_int flags;				/* XXX not used? */
 {
 	struct _hqh *head;
 	BKT *bp;
@@ -227,9 +237,11 @@
  * mpool_put
  *	Return a page.
  */
-/* ARGSUSED */
 int
-mpool_put(MPOOL *mp, void *page, u_int flags)
+mpool_put(mp, page, flags)
+	MPOOL *mp;
+	void *page;
+	u_int flags;
 {
 	BKT *bp;
 
@@ -254,7 +266,8 @@
  *	Close the buffer pool.
  */
 int
-mpool_close(MPOOL *mp)
+mpool_close(mp)
+	MPOOL *mp;
 {
 	BKT *bp;
 
@@ -275,7 +288,8 @@
  *	Sync the pool to disk.
  */
 int
-mpool_sync(MPOOL *mp)
+mpool_sync(mp)
+	MPOOL *mp;
 {
 	BKT *bp;
 
@@ -294,7 +308,8 @@
  *	Get a page from the cache (or create one).
  */
 static BKT *
-mpool_bkt(MPOOL *mp)
+mpool_bkt(mp)
+	MPOOL *mp;
 {
 	struct _hqh *head;
 	BKT *bp;
@@ -332,10 +347,13 @@
 			return (bp);
 		}
 
-new:	if ((bp = (BKT *)calloc(1, sizeof(BKT) + mp->pagesize)) == NULL)
+new:	if ((bp = (BKT *)malloc(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;
@@ -347,7 +365,9 @@
  *	Write a page to disk.
  */
 static int
-mpool_write(MPOOL *mp, BKT *bp)
+mpool_write(mp, bp)
+	MPOOL *mp;
+	BKT *bp;
 {
 	off_t off;
 
@@ -372,7 +392,9 @@
  *	Lookup a page in the cache.
  */
 static BKT *
-mpool_look(MPOOL *mp, pgno_t pgno)
+mpool_look(mp, pgno)
+	MPOOL *mp;
+	pgno_t pgno;
 {
 	struct _hqh *head;
 	BKT *bp;
@@ -397,15 +419,16 @@
  *	Print out cache statistics.
  */
 void
-mpool_stat(MPOOL *mp)
+mpool_stat(mp)
+	MPOOL *mp;
 {
 	BKT *bp;
 	int cnt;
 	char *sep;
 
-	(void)fprintf(stderr, "%lu pages in the file\n", mp->npages);
+	(void)fprintf(stderr, "%u pages in the file\n", mp->npages);
 	(void)fprintf(stderr,
-	    "page size %lu, cacheing %lu pages of %lu page max cache\n",
+	    "page size %lu, cacheing %u pages of %u page max cache\n",
 	    mp->pagesize, mp->curcache, mp->maxcache);
 	(void)fprintf(stderr, "%lu page puts, %lu page gets, %lu page new\n",
 	    mp->pageput, mp->pageget, mp->pagenew);