Alvaro Herrera wrote: > Cleanup ClusterInfo initialization in pg_upgrade
Global structs are already initialized to zero, so no need to initialize them. I discussed this with Alvaro, and he suggested that there is no need to free memory before we exit. The attached, applied patch makes both changes. -- Bruce Momjian <br...@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. +
diff --git a/contrib/pg_upgrade/info.c b/contrib/pg_upgrade/info.c index 7a5a050..0c518a2 100644 *** a/contrib/pg_upgrade/info.c --- b/contrib/pg_upgrade/info.c *************** static void free_rel_infos(RelInfoArr *r *** 22,33 **** static void print_db_infos(DbInfoArr *dbinfo); static void print_rel_infos(RelInfoArr *arr); - void - initialize_cluster_info(ClusterInfo *cluster) - { - cluster->dbarr.ndbs = 0; - cluster->dbarr.dbs = NULL; - } /* * gen_db_file_maps() --- 22,27 ---- diff --git a/contrib/pg_upgrade/pg_upgrade.c b/contrib/pg_upgrade/pg_upgrade.c index 319ee79..061544c 100644 *** a/contrib/pg_upgrade/pg_upgrade.c --- b/contrib/pg_upgrade/pg_upgrade.c *************** main(int argc, char **argv) *** 63,71 **** char *deletion_script_file_name = NULL; bool live_check = false; - initialize_cluster_info(&old_cluster); - initialize_cluster_info(&new_cluster); - parseCommandLine(argc, argv); output_check_banner(&live_check); --- 63,68 ---- *************** set_frozenxids(void) *** 428,458 **** static void cleanup(void) { - int tblnum; char filename[MAXPGPATH]; ! for (tblnum = 0; tblnum < os_info.num_tablespaces; tblnum++) ! pg_free(os_info.tablespaces[tblnum]); ! pg_free(os_info.tablespaces); ! ! free_db_and_rel_infos(&old_cluster.dbarr); ! free_db_and_rel_infos(&new_cluster.dbarr); ! pg_free(log_opts.filename); ! pg_free(os_info.user); ! pg_free(old_cluster.controldata.lc_collate); ! pg_free(new_cluster.controldata.lc_collate); ! pg_free(old_cluster.controldata.lc_ctype); ! pg_free(new_cluster.controldata.lc_ctype); ! pg_free(old_cluster.controldata.encoding); ! pg_free(new_cluster.controldata.encoding); ! pg_free(old_cluster.tablespace_suffix); ! pg_free(new_cluster.tablespace_suffix); ! ! if (log_opts.fd != NULL) ! { fclose(log_opts.fd); - log_opts.fd = NULL; - } if (log_opts.debug_fd) fclose(log_opts.debug_fd); --- 425,434 ---- static void cleanup(void) { char filename[MAXPGPATH]; ! if (log_opts.fd) fclose(log_opts.fd); if (log_opts.debug_fd) fclose(log_opts.debug_fd); diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h index 598625b..4461952 100644 *** a/contrib/pg_upgrade/pg_upgrade.h --- b/contrib/pg_upgrade/pg_upgrade.h *************** void check_loadable_libraries(void); *** 326,332 **** /* info.c */ - void initialize_cluster_info(ClusterInfo *cluster); FileNameMap *gen_db_file_maps(DbInfo *old_db, DbInfo *new_db, int *nmaps, const char *old_pgdata, const char *new_pgdata); --- 326,331 ----
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers