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.
This commit is contained in:
parent
dc73e25a5e
commit
667d5ed206
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 */
|
/* get pointers to the dimensions of shared memory */
|
||||||
ShmemBase = (unsigned long) sharedRegion;
|
ShmemBase = (unsigned long) sharedRegion;
|
||||||
ShmemEnd = (unsigned long) sharedRegion + ShmemSize;
|
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;
|
ShmemFreeStart = (unsigned long *) ShmemBase;
|
||||||
/* next is a shmem pointer to the shmem index */
|
/* next is a shmem pointer to the shmem index */
|
||||||
ShmemIndexOffset = ShmemFreeStart + 1;
|
ShmemIndexOffset = ShmemFreeStart + 1;
|
||||||
/* next is ShmemVariableCache */
|
/* next is ShmemVariableCache */
|
||||||
ShmemVariableCache = (VariableCache) (ShmemIndexOffset + 1);
|
ShmemVariableCache = (VariableCache) (ShmemIndexOffset + 1);
|
||||||
|
|
||||||
currFreeSpace += sizeof(ShmemFreeStart) + sizeof(ShmemIndexOffset) +
|
/* here is where to start dynamic allocation */
|
||||||
LONGALIGN(sizeof(VariableCacheData));
|
currFreeSpace = MAXALIGN(sizeof(*ShmemFreeStart) +
|
||||||
|
sizeof(*ShmemIndexOffset) +
|
||||||
|
sizeof(*ShmemVariableCache));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* bootstrap initialize spin locks so we can start to use the
|
* bootstrap initialize spin locks so we can start to use the
|
||||||
@ -510,7 +511,7 @@ ShmemInitStruct(char *name, Size size, bool *foundPtr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Assert(ShmemIndexOffset);
|
Assert(*ShmemIndexOffset);
|
||||||
|
|
||||||
*foundPtr = TRUE;
|
*foundPtr = TRUE;
|
||||||
return (void *) MAKE_PTR(*ShmemIndexOffset);
|
return (void *) MAKE_PTR(*ShmemIndexOffset);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user