aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/ipc
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-09-27 18:40:10 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-09-27 18:40:10 +0000
commitc92f7e258ee579abd0f95183598edf250d351b2c (patch)
tree10c6b377a74c61b71ece70cfd3cb209795bf1051 /src/backend/storage/ipc
parent996b203e621bc76985ff0156b4f2ef720944b41b (diff)
downloadpostgresql-c92f7e258ee579abd0f95183598edf250d351b2c.tar.gz
postgresql-c92f7e258ee579abd0f95183598edf250d351b2c.zip
Replace strncpy with strlcpy in selected places that seem possibly relevant
to performance. (A wholesale effort to get rid of strncpy should be undertaken sometime, but not during beta.) This commit also fixes dynahash.c to correctly truncate overlength string keys for hashtables, so that its callers don't have to anymore.
Diffstat (limited to 'src/backend/storage/ipc')
-rw-r--r--src/backend/storage/ipc/shmem.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c
index 3c48173f2f6..4cff4c19f33 100644
--- a/src/backend/storage/ipc/shmem.c
+++ b/src/backend/storage/ipc/shmem.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/ipc/shmem.c,v 1.95 2006/08/01 19:03:11 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/ipc/shmem.c,v 1.96 2006/09/27 18:40:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -456,13 +456,9 @@ ShmemInitHash(const char *name, /* table string name for shmem index */
void *
ShmemInitStruct(const char *name, Size size, bool *foundPtr)
{
- ShmemIndexEnt *result,
- item;
+ ShmemIndexEnt *result;
void *structPtr;
- strncpy(item.key, name, SHMEM_INDEX_KEYSIZE);
- item.location = BAD_LOCATION;
-
LWLockAcquire(ShmemIndexLock, LW_EXCLUSIVE);
if (!ShmemIndex)
@@ -498,7 +494,7 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr)
/* look it up in the shmem index */
result = (ShmemIndexEnt *)
- hash_search(ShmemIndex, (void *) &item, HASH_ENTER_NULL, foundPtr);
+ hash_search(ShmemIndex, name, HASH_ENTER_NULL, foundPtr);
if (!result)
{
@@ -533,12 +529,13 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr)
{
/* out of memory */
Assert(ShmemIndex);
- hash_search(ShmemIndex, (void *) &item, HASH_REMOVE, NULL);
+ hash_search(ShmemIndex, name, HASH_REMOVE, NULL);
LWLockRelease(ShmemIndexLock);
ereport(WARNING,
(errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("could not allocate shared memory segment \"%s\"", name)));
+ errmsg("could not allocate shared memory segment \"%s\"",
+ name)));
*foundPtr = FALSE;
return NULL;
}