Skip to content

Commit 667d5ed

Browse files
committed
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.
1 parent dc73e25 commit 667d5ed

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/backend/storage/ipc/shmem.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.52 2000/06/28 03:31:57 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.53 2000/07/25 20:17:02 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -171,17 +171,18 @@ InitShmem(unsigned int key, unsigned int size)
171171
/* get pointers to the dimensions of shared memory */
172172
ShmemBase = (unsigned long) sharedRegion;
173173
ShmemEnd = (unsigned long) sharedRegion + ShmemSize;
174-
currFreeSpace = 0;
175174

176-
/* First long in shared memory is the count of available space */
175+
/* First long in shared memory is the available-space pointer */
177176
ShmemFreeStart = (unsigned long *) ShmemBase;
178177
/* next is a shmem pointer to the shmem index */
179178
ShmemIndexOffset = ShmemFreeStart + 1;
180179
/* next is ShmemVariableCache */
181180
ShmemVariableCache = (VariableCache) (ShmemIndexOffset + 1);
182181

183-
currFreeSpace += sizeof(ShmemFreeStart) + sizeof(ShmemIndexOffset) +
184-
LONGALIGN(sizeof(VariableCacheData));
182+
/* here is where to start dynamic allocation */
183+
currFreeSpace = MAXALIGN(sizeof(*ShmemFreeStart) +
184+
sizeof(*ShmemIndexOffset) +
185+
sizeof(*ShmemVariableCache));
185186

186187
/*
187188
* bootstrap initialize spin locks so we can start to use the
@@ -510,7 +511,7 @@ ShmemInitStruct(char *name, Size size, bool *foundPtr)
510511
}
511512
else
512513
{
513-
Assert(ShmemIndexOffset);
514+
Assert(*ShmemIndexOffset);
514515

515516
*foundPtr = TRUE;
516517
return (void *) MAKE_PTR(*ShmemIndexOffset);

0 commit comments

Comments
 (0)