|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * 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 $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -171,17 +171,18 @@ InitShmem(unsigned int key, unsigned int size)
|
171 | 171 | /* get pointers to the dimensions of shared memory */
|
172 | 172 | ShmemBase = (unsigned long) sharedRegion;
|
173 | 173 | ShmemEnd = (unsigned long) sharedRegion + ShmemSize;
|
174 |
| - currFreeSpace = 0; |
175 | 174 |
|
176 |
| - /* First long in shared memory is the count of available space */ |
| 175 | + /* First long in shared memory is the available-space pointer */ |
177 | 176 | ShmemFreeStart = (unsigned long *) ShmemBase;
|
178 | 177 | /* next is a shmem pointer to the shmem index */
|
179 | 178 | ShmemIndexOffset = ShmemFreeStart + 1;
|
180 | 179 | /* next is ShmemVariableCache */
|
181 | 180 | ShmemVariableCache = (VariableCache) (ShmemIndexOffset + 1);
|
182 | 181 |
|
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)); |
185 | 186 |
|
186 | 187 | /*
|
187 | 188 | * bootstrap initialize spin locks so we can start to use the
|
@@ -510,7 +511,7 @@ ShmemInitStruct(char *name, Size size, bool *foundPtr)
|
510 | 511 | }
|
511 | 512 | else
|
512 | 513 | {
|
513 |
| - Assert(ShmemIndexOffset); |
| 514 | + Assert(*ShmemIndexOffset); |
514 | 515 |
|
515 | 516 | *foundPtr = TRUE;
|
516 | 517 | return (void *) MAKE_PTR(*ShmemIndexOffset);
|
|
0 commit comments