Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

util_cache.c

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2000-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: util_cache.c,v 12.1 2005/06/16 20:20:54 bostic Exp $
00008  */
00009 
00010 #include "db_config.h"
00011 
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <sys/types.h>
00014 
00015 #include <stdlib.h>
00016 
00017 #include <string.h>
00018 #endif
00019 
00020 #include "db_int.h"
00021 
00022 /*
00023  * __db_util_cache --
00024  *      Compute if we have enough cache.
00025  *
00026  * PUBLIC: int __db_util_cache __P((DB *, u_int32_t *, int *));
00027  */
00028 int
00029 __db_util_cache(dbp, cachep, resizep)
00030         DB *dbp;
00031         u_int32_t *cachep;
00032         int *resizep;
00033 {
00034         u_int32_t pgsize;
00035         int ret;
00036 
00037         /* Get the current page size. */
00038         if ((ret = dbp->get_pagesize(dbp, &pgsize)) != 0)
00039                 return (ret);
00040 
00041         /*
00042          * The current cache size is in cachep.  If it's insufficient, set the
00043          * the memory referenced by resizep to 1 and set cachep to the minimum
00044          * size needed.
00045          *
00046          * Make sure our current cache is big enough.  We want at least
00047          * DB_MINPAGECACHE pages in the cache.
00048          */
00049         if ((*cachep / pgsize) < DB_MINPAGECACHE) {
00050                 *resizep = 1;
00051                 *cachep = pgsize * DB_MINPAGECACHE;
00052         } else
00053                 *resizep = 0;
00054 
00055         return (0);
00056 }

Generated on Sun Dec 25 12:14:17 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2