summaryrefslogtreecommitdiff
path: root/src/backend/commands/trigger.c
diff options
context:
space:
mode:
authorTom Lane2015-02-20 22:32:01 +0000
committerTom Lane2015-02-20 22:32:01 +0000
commit33a3b03d636b529b27f869e332b6344d52635331 (patch)
treec5227d0a7013626e9fa9c0973075de224bd4fa33 /src/backend/commands/trigger.c
parentc110eff1324f5c882c737ad988191ed4a54c4936 (diff)
Use FLEXIBLE_ARRAY_MEMBER in some more places.
Fix a batch of structs that are only visible within individual .c files. Michael Paquier
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);
}