From 8a52b893b3d83c6dc796fae6a07a4ac30c871fc4 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 5 Oct 2001 17:28:13 +0000 Subject: Further cleanup of dynahash.c API, in pursuit of portability and readability. Bizarre '(long *) TRUE' return convention is gone, in favor of just raising an error internally in dynahash.c when we detect hashtable corruption. HashTableWalk is gone, in favor of using hash_seq_search directly, since it had no hope of working with non-LONGALIGNable datatypes. Simplify some other code that was made undesirably grotty by promixity to HashTableWalk. --- src/backend/storage/ipc/shmem.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/backend/storage/ipc/shmem.c') diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c index 024db5bd533..32f2cf98a1d 100644 --- a/src/backend/storage/ipc/shmem.c +++ b/src/backend/storage/ipc/shmem.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.60 2001/10/01 05:36:14 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.61 2001/10/05 17:28:12 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -210,7 +210,7 @@ InitShmemIndex(void) result = (ShmemIndexEnt *) hash_search(ShmemIndex, (void *) &item, HASH_ENTER, &found); if (!result) - elog(FATAL, "InitShmemIndex: corrupted shmem index"); + elog(FATAL, "InitShmemIndex: Shmem Index out of memory"); Assert(ShmemBootstrap && !found); @@ -234,7 +234,7 @@ InitShmemIndex(void) * table at once. */ HTAB * -ShmemInitHash(char *name, /* table string name for shmem index */ +ShmemInitHash(const char *name, /* table string name for shmem index */ long init_size, /* initial table size */ long max_size, /* max size of the table */ HASHCTL *infoP, /* info about key and bucket size */ @@ -277,7 +277,7 @@ ShmemInitHash(char *name, /* table string name for shmem index */ infoP->hctl = (HASHHDR *) location; infoP->dir = (HASHSEGMENT *) (((char *) location) + sizeof(HASHHDR)); - return hash_create(init_size, infoP, hash_flags); + return hash_create(name, init_size, infoP, hash_flags); } /* @@ -295,7 +295,7 @@ ShmemInitHash(char *name, /* table string name for shmem index */ * initialized). */ void * -ShmemInitStruct(char *name, Size size, bool *foundPtr) +ShmemInitStruct(const char *name, Size size, bool *foundPtr) { ShmemIndexEnt *result, item; @@ -328,7 +328,7 @@ ShmemInitStruct(char *name, Size size, bool *foundPtr) if (!result) { LWLockRelease(ShmemIndexLock); - elog(ERROR, "ShmemInitStruct: Shmem Index corrupted"); + elog(ERROR, "ShmemInitStruct: Shmem Index out of memory"); return NULL; } @@ -357,12 +357,12 @@ ShmemInitStruct(char *name, Size size, bool *foundPtr) { /* out of memory */ Assert(ShmemIndex); - hash_search(ShmemIndex, (void *) &item, HASH_REMOVE, foundPtr); + hash_search(ShmemIndex, (void *) &item, HASH_REMOVE, NULL); LWLockRelease(ShmemIndexLock); - *foundPtr = FALSE; elog(NOTICE, "ShmemInitStruct: cannot allocate '%s'", name); + *foundPtr = FALSE; return NULL; } result->size = size; -- cgit v1.2.3