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
{
/* 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 \
*/
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;
pfield = (PGMessageField *)
pqResultAlloc(res,
- sizeof(PGMessageField) + strlen(value),
+ offsetof(PGMessageField, contents) +
+ strlen(value) + 1,
TRUE);
if (!pfield)
return; /* out of memory? */
{
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 */
* The SSL implementatation provides these functions (fe-secure-openssl.c)
*/
extern void pgtls_init_library(bool do_ssl, int do_crypto);
-extern int pgtls_init(PGconn *conn);
+extern int pgtls_init(PGconn *conn);
extern PostgresPollingStatusType pgtls_open_client(PGconn *conn);
extern void pgtls_close(PGconn *conn);
extern ssize_t pgtls_read(PGconn *conn, void *ptr, size_t len);
/* 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;
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;