Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit33a3b03

Browse files
committed
Use FLEXIBLE_ARRAY_MEMBER in some more places.
Fix a batch of structs that are only visible within individual .c files.Michael Paquier
1 parentc110eff commit33a3b03

File tree

11 files changed

+32
-37
lines changed

11 files changed

+32
-37
lines changed

‎src/backend/access/nbtree/nbtutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,7 @@ typedef struct BTVacInfo
18361836
BTCycleIdcycle_ctr;/* cycle ID most recently assigned */
18371837
intnum_vacuums;/* number of currently active VACUUMs */
18381838
intmax_vacuums;/* allocated length of vacuums[] array */
1839-
BTOneVacInfovacuums[1];/* VARIABLE LENGTH ARRAY */
1839+
BTOneVacInfovacuums[FLEXIBLE_ARRAY_MEMBER];
18401840
}BTVacInfo;
18411841

18421842
staticBTVacInfo*btvacinfo;
@@ -1984,7 +1984,7 @@ BTreeShmemSize(void)
19841984
{
19851985
Sizesize;
19861986

1987-
size= offsetof(BTVacInfo,vacuums[0]);
1987+
size= offsetof(BTVacInfo,vacuums);
19881988
size=add_size(size,mul_size(MaxBackends,sizeof(BTOneVacInfo)));
19891989
returnsize;
19901990
}

‎src/backend/access/transam/multixact.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ typedef struct MultiXactStateData
258258
* stored in pg_control and used as truncation point for pg_multixact. At
259259
* checkpoint or restartpoint, unneeded segments are removed.
260260
*/
261-
MultiXactIdperBackendXactIds[1];/* VARIABLE LENGTH ARRAY */
261+
MultiXactIdperBackendXactIds[FLEXIBLE_ARRAY_MEMBER];
262262
}MultiXactStateData;
263263

264264
/*
@@ -1744,8 +1744,9 @@ MultiXactShmemSize(void)
17441744
{
17451745
Sizesize;
17461746

1747+
/* We need 2*MaxOldestSlot + 1 perBackendXactIds[] entries */
17471748
#defineSHARED_MULTIXACT_STATE_SIZE \
1748-
add_size(sizeof(MultiXactStateData), \
1749+
add_size(offsetof(MultiXactStateData, perBackendXactIds) + sizeof(MultiXactId), \
17491750
mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
17501751

17511752
size=SHARED_MULTIXACT_STATE_SIZE;

‎src/backend/access/transam/twophase.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,9 @@ typedef struct TwoPhaseStateData
134134
/* Number of valid prepXacts entries. */
135135
intnumPrepXacts;
136136

137-
/*
138-
* There are max_prepared_xacts items in this array, but C wants a
139-
* fixed-size array.
140-
*/
141-
GlobalTransactionprepXacts[1];/* VARIABLE LENGTH ARRAY */
142-
}TwoPhaseStateData;/* VARIABLE LENGTH STRUCT */
137+
/* There are max_prepared_xacts items in this array */
138+
GlobalTransactionprepXacts[FLEXIBLE_ARRAY_MEMBER];
139+
}TwoPhaseStateData;
143140

144141
staticTwoPhaseStateData*TwoPhaseState;
145142

‎src/backend/commands/tablespace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ GetDefaultTablespace(char relpersistence)
10881088
typedefstruct
10891089
{
10901090
intnumSpcs;
1091-
OidtblSpcs[1];/* VARIABLE LENGTH ARRAY */
1091+
OidtblSpcs[FLEXIBLE_ARRAY_MEMBER];
10921092
}temp_tablespaces_extra;
10931093

10941094
/* check_hook: validate new temp_tablespaces */

‎src/backend/commands/trigger.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,7 +3005,7 @@ typedef struct SetConstraintStateData
30053005
boolall_isdeferred;
30063006
intnumstates;/* number of trigstates[] entries in use */
30073007
intnumalloc;/* allocated size of trigstates[] */
3008-
SetConstraintTriggerDatatrigstates[1];/* VARIABLE LENGTH ARRAY */
3008+
SetConstraintTriggerDatatrigstates[FLEXIBLE_ARRAY_MEMBER];
30093009
}SetConstraintStateData;
30103010

30113011
typedefSetConstraintStateData*SetConstraintState;
@@ -4398,8 +4398,8 @@ SetConstraintStateCreate(int numalloc)
43984398
*/
43994399
state= (SetConstraintState)
44004400
MemoryContextAllocZero(TopTransactionContext,
4401-
sizeof(SetConstraintStateData)+
4402-
(numalloc-1)*sizeof(SetConstraintTriggerData));
4401+
offsetof(SetConstraintStateData,trigstates)+
4402+
numalloc*sizeof(SetConstraintTriggerData));
44034403

44044404
state->numalloc=numalloc;
44054405

@@ -4440,8 +4440,8 @@ SetConstraintStateAddItem(SetConstraintState state,
44404440
newalloc=Max(newalloc,8);/* in case original has size 0 */
44414441
state= (SetConstraintState)
44424442
repalloc(state,
4443-
sizeof(SetConstraintStateData)+
4444-
(newalloc-1)*sizeof(SetConstraintTriggerData));
4443+
offsetof(SetConstraintStateData,trigstates)+
4444+
newalloc*sizeof(SetConstraintTriggerData));
44454445
state->numalloc=newalloc;
44464446
Assert(state->numstates<state->numalloc);
44474447
}

‎src/backend/executor/nodeAgg.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ typedef struct AggHashEntryData *AggHashEntry;
297297
typedefstructAggHashEntryData
298298
{
299299
TupleHashEntryDatashared;/* common header for hash table entries */
300-
/* per-aggregate transition status array- must be last!*/
301-
AggStatePerGroupDatapergroup[1];/* VARIABLE LENGTH ARRAY */
302-
}AggHashEntryData;/* VARIABLE LENGTH STRUCT */
300+
/* per-aggregate transition status array */
301+
AggStatePerGroupDatapergroup[FLEXIBLE_ARRAY_MEMBER];
302+
}AggHashEntryData;
303303

304304

305305
staticvoidinitialize_aggregates(AggState*aggstate,
@@ -941,8 +941,8 @@ build_hash_table(AggState *aggstate)
941941
Assert(node->aggstrategy==AGG_HASHED);
942942
Assert(node->numGroups>0);
943943

944-
entrysize=sizeof(AggHashEntryData)+
945-
(aggstate->numaggs-1)*sizeof(AggStatePerGroupData);
944+
entrysize=offsetof(AggHashEntryData,pergroup)+
945+
aggstate->numaggs*sizeof(AggStatePerGroupData);
946946

947947
aggstate->hashtable=BuildTupleHashTable(node->numCols,
948948
node->grpColIdx,
@@ -1013,8 +1013,8 @@ hash_agg_entry_size(int numAggs)
10131013
Sizeentrysize;
10141014

10151015
/* This must match build_hash_table */
1016-
entrysize=sizeof(AggHashEntryData)+
1017-
(numAggs-1)*sizeof(AggStatePerGroupData);
1016+
entrysize=offsetof(AggHashEntryData,pergroup)+
1017+
numAggs*sizeof(AggStatePerGroupData);
10181018
entrysize=MAXALIGN(entrysize);
10191019
/* Account for hashtable overhead (assuming fill factor = 1) */
10201020
entrysize+=3*sizeof(void*);

‎src/backend/postmaster/checkpointer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ typedef struct
130130

131131
intnum_requests;/* current # of requests */
132132
intmax_requests;/* allocated array size */
133-
CheckpointerRequestrequests[1];/* VARIABLE LENGTH ARRAY */
133+
CheckpointerRequestrequests[FLEXIBLE_ARRAY_MEMBER];
134134
}CheckpointerShmemStruct;
135135

136136
staticCheckpointerShmemStruct*CheckpointerShmem;

‎src/backend/storage/ipc/pmsignal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct PMSignalData
6666
/* per-child-process flags */
6767
intnum_child_flags;/* # of entries in PMChildFlags[] */
6868
intnext_child_flag;/* next slot to try to assign */
69-
sig_atomic_tPMChildFlags[1];/* VARIABLE LENGTH ARRAY */
69+
sig_atomic_tPMChildFlags[FLEXIBLE_ARRAY_MEMBER];
7070
};
7171

7272
NON_EXEC_STATICvolatilePMSignalData*PMSignalState=NULL;

‎src/backend/storage/ipc/procarray.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,8 @@ typedef struct ProcArrayStruct
9090
/* oldest catalog xmin of any replication slot */
9191
TransactionIdreplication_slot_catalog_xmin;
9292

93-
/*
94-
* We declare pgprocnos[] as 1 entry because C wants a fixed-size array,
95-
* but actually it is maxProcs entries long.
96-
*/
97-
intpgprocnos[1];/* VARIABLE LENGTH ARRAY */
93+
/* indexes into allPgXact[], has PROCARRAY_MAXPROCS entries */
94+
intpgprocnos[FLEXIBLE_ARRAY_MEMBER];
9895
}ProcArrayStruct;
9996

10097
staticProcArrayStruct*procArray;

‎src/backend/utils/cache/inval.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ typedef struct InvalidationChunk
122122
structInvalidationChunk*next;/* list link */
123123
intnitems;/* # items currently stored in chunk */
124124
intmaxitems;/* size of allocated array in this chunk */
125-
SharedInvalidationMessagemsgs[1];/* VARIABLE LENGTH ARRAY */
126-
}InvalidationChunk;/* VARIABLE LENGTH STRUCTURE */
125+
SharedInvalidationMessagemsgs[FLEXIBLE_ARRAY_MEMBER];
126+
}InvalidationChunk;
127127

128128
typedefstructInvalidationListHeader
129129
{
@@ -225,8 +225,8 @@ AddInvalidationMessage(InvalidationChunk **listHdr,
225225
#defineFIRSTCHUNKSIZE 32
226226
chunk= (InvalidationChunk*)
227227
MemoryContextAlloc(CurTransactionContext,
228-
sizeof(InvalidationChunk)+
229-
(FIRSTCHUNKSIZE-1)*sizeof(SharedInvalidationMessage));
228+
offsetof(InvalidationChunk,msgs)+
229+
FIRSTCHUNKSIZE*sizeof(SharedInvalidationMessage));
230230
chunk->nitems=0;
231231
chunk->maxitems=FIRSTCHUNKSIZE;
232232
chunk->next=*listHdr;
@@ -239,8 +239,8 @@ AddInvalidationMessage(InvalidationChunk **listHdr,
239239

240240
chunk= (InvalidationChunk*)
241241
MemoryContextAlloc(CurTransactionContext,
242-
sizeof(InvalidationChunk)+
243-
(chunksize-1)*sizeof(SharedInvalidationMessage));
242+
offsetof(InvalidationChunk,msgs)+
243+
chunksize*sizeof(SharedInvalidationMessage));
244244
chunk->nitems=0;
245245
chunk->maxitems=chunksize;
246246
chunk->next=*listHdr;

‎src/backend/utils/cache/typcache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ typedef struct TypeCacheEnumData
9393
Oidbitmap_base;/* OID corresponding to bit 0 of bitmapset */
9494
Bitmapset*sorted_values;/* Set of OIDs known to be in order */
9595
intnum_values;/* total number of values in enum */
96-
EnumItemenum_values[1];/* VARIABLE LENGTH ARRAY */
96+
EnumItemenum_values[FLEXIBLE_ARRAY_MEMBER];
9797
}TypeCacheEnumData;
9898

9999
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp