Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2a7b2d9

Browse files
committed
Improve InitShmemAccess() prototype
The code comment said, 'the argument should be declared "PGShmemHeader *seghdr", but we use void to avoid having to include ipc.h in shmem.h.' We can achieve the original goal with a struct forward declaration. (ipc.h was also not the correct header file.) Discussion: https://www.postgresql.org/message-id/flat/cnthxg2eekacrejyeonuhiaezc7vd7o2uowlsbenxqfkjwgvwj@qgzu6eoqrglb
1 parent e15e567 commit 2a7b2d9

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/backend/storage/ipc/shmem.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,13 @@ static HTAB *ShmemIndex = NULL; /* primary index hashtable for shmem */
9292

9393
/*
9494
* InitShmemAccess() --- set up basic pointers to shared memory.
95-
*
96-
* Note: the argument should be declared "PGShmemHeader *seghdr",
97-
* but we use void to avoid having to include ipc.h in shmem.h.
9895
*/
9996
void
100-
InitShmemAccess(void *seghdr)
97+
InitShmemAccess(PGShmemHeader *seghdr)
10198
{
102-
PGShmemHeader *shmhdr = (PGShmemHeader *) seghdr;
103-
104-
ShmemSegHdr = shmhdr;
105-
ShmemBase = (void *) shmhdr;
106-
ShmemEnd = (char *) ShmemBase + shmhdr->totalsize;
99+
ShmemSegHdr = seghdr;
100+
ShmemBase = seghdr;
101+
ShmemEnd = (char *) ShmemBase + seghdr->totalsize;
107102
}
108103

109104
/*

src/include/storage/shmem.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727

2828
/* shmem.c */
2929
extern PGDLLIMPORT slock_t *ShmemLock;
30-
extern void InitShmemAccess(void *seghdr);
30+
struct PGShmemHeader; /* avoid including storage/pg_shmem.h here */
31+
extern void InitShmemAccess(struct PGShmemHeader *seghdr);
3132
extern void InitShmemAllocation(void);
3233
extern void *ShmemAlloc(Size size);
3334
extern void *ShmemAllocNoError(Size size);

0 commit comments

Comments
 (0)