Commit f2874feb authored by Tom Lane's avatar Tom Lane

Some more FLEXIBLE_ARRAY_MEMBER fixes.

parent 33b2a2c9
......@@ -41,9 +41,8 @@ typedef struct
int num_vars; /* number of plain Var tlist entries */
bool has_ph_vars; /* are there PlaceHolderVar entries? */
bool has_non_vars; /* are there other entries? */
/* array of num_vars entries: */
tlist_vinfo vars[1]; /* VARIABLE LENGTH ARRAY */
} indexed_tlist; /* VARIABLE LENGTH STRUCT */
tlist_vinfo vars[FLEXIBLE_ARRAY_MEMBER]; /* has num_vars entries */
} indexed_tlist;
typedef struct
{
......
......@@ -56,7 +56,12 @@ typedef struct BrinMetaPageData
/* Definitions for revmap pages */
typedef struct RevmapContents
{
ItemPointerData rm_tids[1]; /* really REVMAP_PAGE_MAXITEMS */
/*
* This array will fill all available space on the page. It should be
* declared [FLEXIBLE_ARRAY_MEMBER], but for some reason you can't do that
* in an otherwise-empty struct.
*/
ItemPointerData rm_tids[1];
} RevmapContents;
#define REVMAP_CONTENT_SIZE \
......
......@@ -130,6 +130,10 @@ typedef struct ReplicationSlot
*/
typedef struct ReplicationSlotCtlData
{
/*
* This array should be declared [FLEXIBLE_ARRAY_MEMBER], but for some
* reason you can't do that in an otherwise-empty struct.
*/
ReplicationSlot replication_slots[1];
} ReplicationSlotCtlData;
......
......@@ -892,7 +892,8 @@ pqSaveMessageField(PGresult *res, char code, const char *value)
pfield = (PGMessageField *)
pqResultAlloc(res,
sizeof(PGMessageField) + strlen(value),
offsetof(PGMessageField, contents) +
strlen(value) + 1,
TRUE);
if (!pfield)
return; /* out of memory? */
......
......@@ -145,7 +145,7 @@ typedef struct pgMessageField
{
struct pgMessageField *next; /* list link */
char code; /* field code */
char contents[1]; /* field value (VARIABLE LENGTH) */
char contents[FLEXIBLE_ARRAY_MEMBER]; /* value, nul-terminated */
} PGMessageField;
/* Fields needed for notice handling */
......
......@@ -97,7 +97,7 @@ plpgsql_ns_additem(int itemtype, int itemno, const char *name)
/* first item added must be a label */
Assert(ns_top != NULL || itemtype == PLPGSQL_NSTYPE_LABEL);
nse = palloc(sizeof(PLpgSQL_nsitem) + strlen(name));
nse = palloc(offsetof(PLpgSQL_nsitem, name) +strlen(name) + 1);
nse->itemtype = itemtype;
nse->itemno = itemno;
nse->prev = ns_top;
......
......@@ -329,7 +329,7 @@ typedef struct PLpgSQL_nsitem
int itemtype;
int itemno;
struct PLpgSQL_nsitem *prev;
char name[1]; /* actually, as long as needed */
char name[FLEXIBLE_ARRAY_MEMBER]; /* nul-terminated string */
} PLpgSQL_nsitem;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment