Fix a batch of structs that are only visible within individual .c files.
Michael Paquier
BTCycleId cycle_ctr; /* cycle ID most recently assigned */
int num_vacuums; /* number of currently active VACUUMs */
int max_vacuums; /* allocated length of vacuums[] array */
- BTOneVacInfo vacuums[1]; /* VARIABLE LENGTH ARRAY */
+ BTOneVacInfo vacuums[FLEXIBLE_ARRAY_MEMBER];
} BTVacInfo;
static BTVacInfo *btvacinfo;
{
Size size;
- size = offsetof(BTVacInfo, vacuums[0]);
+ size = offsetof(BTVacInfo, vacuums);
size = add_size(size, mul_size(MaxBackends, sizeof(BTOneVacInfo)));
return size;
}
* stored in pg_control and used as truncation point for pg_multixact. At
* checkpoint or restartpoint, unneeded segments are removed.
*/
- MultiXactId perBackendXactIds[1]; /* VARIABLE LENGTH ARRAY */
+ MultiXactId perBackendXactIds[FLEXIBLE_ARRAY_MEMBER];
} MultiXactStateData;
/*
{
Size size;
+ /* We need 2*MaxOldestSlot + 1 perBackendXactIds[] entries */
#define SHARED_MULTIXACT_STATE_SIZE \
- add_size(sizeof(MultiXactStateData), \
+ add_size(offsetof(MultiXactStateData, perBackendXactIds) + sizeof(MultiXactId), \
mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
size = SHARED_MULTIXACT_STATE_SIZE;
/* Number of valid prepXacts entries. */
int numPrepXacts;
- /*
- * There are max_prepared_xacts items in this array, but C wants a
- * fixed-size array.
- */
- GlobalTransaction prepXacts[1]; /* VARIABLE LENGTH ARRAY */
-} TwoPhaseStateData; /* VARIABLE LENGTH STRUCT */
+ /* There are max_prepared_xacts items in this array */
+ GlobalTransaction prepXacts[FLEXIBLE_ARRAY_MEMBER];
+} TwoPhaseStateData;
static TwoPhaseStateData *TwoPhaseState;
typedef struct
{
int numSpcs;
- Oid tblSpcs[1]; /* VARIABLE LENGTH ARRAY */
+ Oid tblSpcs[FLEXIBLE_ARRAY_MEMBER];
} temp_tablespaces_extra;
/* check_hook: validate new temp_tablespaces */
bool all_isdeferred;
int numstates; /* number of trigstates[] entries in use */
int numalloc; /* allocated size of trigstates[] */
- SetConstraintTriggerData trigstates[1]; /* VARIABLE LENGTH ARRAY */
+ SetConstraintTriggerData trigstates[FLEXIBLE_ARRAY_MEMBER];
} SetConstraintStateData;
typedef SetConstraintStateData *SetConstraintState;
*/
state = (SetConstraintState)
MemoryContextAllocZero(TopTransactionContext,
- sizeof(SetConstraintStateData) +
- (numalloc - 1) *sizeof(SetConstraintTriggerData));
+ offsetof(SetConstraintStateData, trigstates) +
+ numalloc * sizeof(SetConstraintTriggerData));
state->numalloc = numalloc;
newalloc = Max(newalloc, 8); /* in case original has size 0 */
state = (SetConstraintState)
repalloc(state,
- sizeof(SetConstraintStateData) +
- (newalloc - 1) *sizeof(SetConstraintTriggerData));
+ offsetof(SetConstraintStateData, trigstates) +
+ newalloc * sizeof(SetConstraintTriggerData));
state->numalloc = newalloc;
Assert(state->numstates < state->numalloc);
}
typedef struct AggHashEntryData
{
TupleHashEntryData shared; /* common header for hash table entries */
- /* per-aggregate transition status array - must be last! */
- AggStatePerGroupData pergroup[1]; /* VARIABLE LENGTH ARRAY */
-} AggHashEntryData; /* VARIABLE LENGTH STRUCT */
+ /* per-aggregate transition status array */
+ AggStatePerGroupData pergroup[FLEXIBLE_ARRAY_MEMBER];
+} AggHashEntryData;
static void initialize_aggregates(AggState *aggstate,
Assert(node->aggstrategy == AGG_HASHED);
Assert(node->numGroups > 0);
- entrysize = sizeof(AggHashEntryData) +
- (aggstate->numaggs - 1) * sizeof(AggStatePerGroupData);
+ entrysize = offsetof(AggHashEntryData, pergroup) +
+ aggstate->numaggs * sizeof(AggStatePerGroupData);
aggstate->hashtable = BuildTupleHashTable(node->numCols,
node->grpColIdx,
Size entrysize;
/* This must match build_hash_table */
- entrysize = sizeof(AggHashEntryData) +
- (numAggs - 1) * sizeof(AggStatePerGroupData);
+ entrysize = offsetof(AggHashEntryData, pergroup) +
+ numAggs * sizeof(AggStatePerGroupData);
entrysize = MAXALIGN(entrysize);
/* Account for hashtable overhead (assuming fill factor = 1) */
entrysize += 3 * sizeof(void *);
int num_requests; /* current # of requests */
int max_requests; /* allocated array size */
- CheckpointerRequest requests[1]; /* VARIABLE LENGTH ARRAY */
+ CheckpointerRequest requests[FLEXIBLE_ARRAY_MEMBER];
} CheckpointerShmemStruct;
static CheckpointerShmemStruct *CheckpointerShmem;
/* per-child-process flags */
int num_child_flags; /* # of entries in PMChildFlags[] */
int next_child_flag; /* next slot to try to assign */
- sig_atomic_t PMChildFlags[1]; /* VARIABLE LENGTH ARRAY */
+ sig_atomic_t PMChildFlags[FLEXIBLE_ARRAY_MEMBER];
};
NON_EXEC_STATIC volatile PMSignalData *PMSignalState = NULL;
/* oldest catalog xmin of any replication slot */
TransactionId replication_slot_catalog_xmin;
- /*
- * We declare pgprocnos[] as 1 entry because C wants a fixed-size array,
- * but actually it is maxProcs entries long.
- */
- int pgprocnos[1]; /* VARIABLE LENGTH ARRAY */
+ /* indexes into allPgXact[], has PROCARRAY_MAXPROCS entries */
+ int pgprocnos[FLEXIBLE_ARRAY_MEMBER];
} ProcArrayStruct;
static ProcArrayStruct *procArray;
struct InvalidationChunk *next; /* list link */
int nitems; /* # items currently stored in chunk */
int maxitems; /* size of allocated array in this chunk */
- SharedInvalidationMessage msgs[1]; /* VARIABLE LENGTH ARRAY */
-} InvalidationChunk; /* VARIABLE LENGTH STRUCTURE */
+ SharedInvalidationMessage msgs[FLEXIBLE_ARRAY_MEMBER];
+} InvalidationChunk;
typedef struct InvalidationListHeader
{
#define FIRSTCHUNKSIZE 32
chunk = (InvalidationChunk *)
MemoryContextAlloc(CurTransactionContext,
- sizeof(InvalidationChunk) +
- (FIRSTCHUNKSIZE - 1) *sizeof(SharedInvalidationMessage));
+ offsetof(InvalidationChunk, msgs) +
+ FIRSTCHUNKSIZE * sizeof(SharedInvalidationMessage));
chunk->nitems = 0;
chunk->maxitems = FIRSTCHUNKSIZE;
chunk->next = *listHdr;
chunk = (InvalidationChunk *)
MemoryContextAlloc(CurTransactionContext,
- sizeof(InvalidationChunk) +
- (chunksize - 1) *sizeof(SharedInvalidationMessage));
+ offsetof(InvalidationChunk, msgs) +
+ chunksize * sizeof(SharedInvalidationMessage));
chunk->nitems = 0;
chunk->maxitems = chunksize;
chunk->next = *listHdr;
Oid bitmap_base; /* OID corresponding to bit 0 of bitmapset */
Bitmapset *sorted_values; /* Set of OIDs known to be in order */
int num_values; /* total number of values in enum */
- EnumItem enum_values[1]; /* VARIABLE LENGTH ARRAY */
+ EnumItem enum_values[FLEXIBLE_ARRAY_MEMBER];
} TypeCacheEnumData;
/*