Skip to content
Snippets Groups Projects
Commit 667d5ed2 authored by Tom Lane's avatar Tom Lane
Browse files

Fix confusion between sizeof(long) and sizeof(long*), as well as

failure to MAXALIGN the start of shmem allocable space.  No reports
of trouble here, just compulsive tidiness.
parent dc73e25a
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.52 2000/06/28 03:31:57 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.53 2000/07/25 20:17:02 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -171,17 +171,18 @@ InitShmem(unsigned int key, unsigned int size)
/* get pointers to the dimensions of shared memory */
ShmemBase = (unsigned long) sharedRegion;
ShmemEnd = (unsigned long) sharedRegion + ShmemSize;
currFreeSpace = 0;
/* First long in shared memory is the count of available space */
/* First long in shared memory is the available-space pointer */
ShmemFreeStart = (unsigned long *) ShmemBase;
/* next is a shmem pointer to the shmem index */
ShmemIndexOffset = ShmemFreeStart + 1;
/* next is ShmemVariableCache */
ShmemVariableCache = (VariableCache) (ShmemIndexOffset + 1);
currFreeSpace += sizeof(ShmemFreeStart) + sizeof(ShmemIndexOffset) +
LONGALIGN(sizeof(VariableCacheData));
/* here is where to start dynamic allocation */
currFreeSpace = MAXALIGN(sizeof(*ShmemFreeStart) +
sizeof(*ShmemIndexOffset) +
sizeof(*ShmemVariableCache));
/*
* bootstrap initialize spin locks so we can start to use the
......@@ -510,7 +511,7 @@ ShmemInitStruct(char *name, Size size, bool *foundPtr)
}
else
{
Assert(ShmemIndexOffset);
Assert(*ShmemIndexOffset);
*foundPtr = TRUE;
return (void *) MAKE_PTR(*ShmemIndexOffset);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment