diff options
Diffstat (limited to 'src/backend/utils/cache/catcache.c')
-rw-r--r-- | src/backend/utils/cache/catcache.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 10289e03231..be7afe0a5f2 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.7 1997/08/19 21:34:58 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.8 1997/08/24 23:07:42 momjian Exp $ * * Notes: * XXX This needs to use exception.h to handle recovery when @@ -656,8 +656,19 @@ InitSysCache(char *relname, * and the LRU tuple list * ---------------- */ - for (i = 0; i <= NCCBUCK; ++i) { - cp->cc_cache[i] = DLNewList(); + { + /* + * We can only do this optimization because the number of hash + * buckets never changes. Without it, we call malloc() too much. + * We could move this to dllist.c, but the way we do this is not + * dynamic/portabl, so why allow other routines to use it. + */ + void *cache_begin = malloc((NCCBUCK+1)*sizeof(Dllist)); + for (i = 0; i <= NCCBUCK; ++i) { + cp->cc_cache[i] = cache_begin + i * sizeof(Dllist); + cp->cc_cache[i]->dll_head = 0; + cp->cc_cache[i]->dll_tail = 0; + } } cp->cc_lrulist = DLNewList(); |