diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2015-02-20 17:03:12 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2015-02-20 17:03:12 -0500 |
commit | c110eff1324f5c882c737ad988191ed4a54c4936 (patch) | |
tree | 79edcfe6548f724a9141531f50d3ba68566a1428 /src/backend/utils/adt/jsonfuncs.c | |
parent | e38b1eb0986990d539e056a65c6b122b295ce932 (diff) | |
download | postgresql-c110eff1324f5c882c737ad988191ed4a54c4936.tar.gz postgresql-c110eff1324f5c882c737ad988191ed4a54c4936.zip |
Use FLEXIBLE_ARRAY_MEMBER in struct RecordIOData.
I (tgl) fixed this last night in rowtypes.c, but I missed that the
code had been copied into a couple of other places.
Michael Paquier
Diffstat (limited to 'src/backend/utils/adt/jsonfuncs.c')
-rw-r--r-- | src/backend/utils/adt/jsonfuncs.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c index 3688163d914..a8cdeaa393c 100644 --- a/src/backend/utils/adt/jsonfuncs.c +++ b/src/backend/utils/adt/jsonfuncs.c @@ -216,7 +216,7 @@ typedef struct RecordIOData Oid record_type; int32 record_typmod; int ncolumns; - ColumnIOData columns[1]; /* VARIABLE LENGTH ARRAY */ + ColumnIOData columns[FLEXIBLE_ARRAY_MEMBER]; } RecordIOData; /* state for populate_recordset */ @@ -2148,8 +2148,8 @@ populate_record_worker(FunctionCallInfo fcinfo, const char *funcname, { fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, - sizeof(RecordIOData) - sizeof(ColumnIOData) - + ncolumns * sizeof(ColumnIOData)); + offsetof(RecordIOData, columns) + + ncolumns * sizeof(ColumnIOData)); my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra; my_extra->record_type = InvalidOid; my_extra->record_typmod = 0; @@ -2161,8 +2161,8 @@ populate_record_worker(FunctionCallInfo fcinfo, const char *funcname, my_extra->record_typmod != tupTypmod)) { MemSet(my_extra, 0, - sizeof(RecordIOData) - sizeof(ColumnIOData) - + ncolumns * sizeof(ColumnIOData)); + offsetof(RecordIOData, columns) + + ncolumns * sizeof(ColumnIOData)); my_extra->record_type = tupType; my_extra->record_typmod = tupTypmod; my_extra->ncolumns = ncolumns; @@ -2653,8 +2653,8 @@ populate_recordset_worker(FunctionCallInfo fcinfo, const char *funcname, { fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, - sizeof(RecordIOData) - sizeof(ColumnIOData) - + ncolumns * sizeof(ColumnIOData)); + offsetof(RecordIOData, columns) + + ncolumns * sizeof(ColumnIOData)); my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra; my_extra->record_type = InvalidOid; my_extra->record_typmod = 0; @@ -2664,8 +2664,8 @@ populate_recordset_worker(FunctionCallInfo fcinfo, const char *funcname, my_extra->record_typmod != tupTypmod) { MemSet(my_extra, 0, - sizeof(RecordIOData) - sizeof(ColumnIOData) - + ncolumns * sizeof(ColumnIOData)); + offsetof(RecordIOData, columns) + + ncolumns * sizeof(ColumnIOData)); my_extra->record_type = tupType; my_extra->record_typmod = tupTypmod; my_extra->ncolumns = ncolumns; |