diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2015-02-21 16:12:14 -0500 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2015-02-21 16:12:14 -0500 |
| commit | 2e211211a76782b6084194a5ced94c0795460047 (patch) | |
| tree | f98c4ff74b421ecb675e5192c0c1759546d22a86 /src/backend/utils/fmgr/dfmgr.c | |
| parent | e1a11d93111ff3fba7a91f3f2ac0b0aca16909a8 (diff) | |
| download | postgresql-2e211211a76782b6084194a5ced94c0795460047.tar.gz | |
Use FLEXIBLE_ARRAY_MEMBER in a number of other places.
I think we're about done with this...
Diffstat (limited to 'src/backend/utils/fmgr/dfmgr.c')
| -rw-r--r-- | src/backend/utils/fmgr/dfmgr.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c index 1b6932235c..7476a26b79 100644 --- a/src/backend/utils/fmgr/dfmgr.c +++ b/src/backend/utils/fmgr/dfmgr.c @@ -51,12 +51,7 @@ typedef struct df_files ino_t inode; /* Inode number of file */ #endif void *handle; /* a handle for pg_dl* functions */ - char filename[1]; /* Full pathname of file */ - - /* - * we allocate the block big enough for actual length of pathname. - * filename[] must be last item in struct! - */ + char filename[FLEXIBLE_ARRAY_MEMBER]; /* Full pathname of file */ } DynamicFileList; static DynamicFileList *file_list = NULL; @@ -217,13 +212,13 @@ internal_load_library(const char *libname) * File not loaded yet. */ file_scanner = (DynamicFileList *) - malloc(sizeof(DynamicFileList) + strlen(libname)); + malloc(offsetof(DynamicFileList, filename) +strlen(libname) + 1); if (file_scanner == NULL) ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory"))); - MemSet(file_scanner, 0, sizeof(DynamicFileList)); + MemSet(file_scanner, 0, offsetof(DynamicFileList, filename)); strcpy(file_scanner->filename, libname); file_scanner->device = stat_buf.st_dev; #ifndef WIN32 |
