aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/trigger.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/trigger.c')
-rw-r--r--src/backend/commands/trigger.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 5c1c1beb2b8..a84e86ef805 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -3005,7 +3005,7 @@ typedef struct SetConstraintStateData
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;
@@ -4398,8 +4398,8 @@ SetConstraintStateCreate(int numalloc)
*/
state = (SetConstraintState)
MemoryContextAllocZero(TopTransactionContext,
- sizeof(SetConstraintStateData) +
- (numalloc - 1) *sizeof(SetConstraintTriggerData));
+ offsetof(SetConstraintStateData, trigstates) +
+ numalloc * sizeof(SetConstraintTriggerData));
state->numalloc = numalloc;
@@ -4440,8 +4440,8 @@ SetConstraintStateAddItem(SetConstraintState state,
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);
}