From 497e65f822ff33ed964d1c891ee6de0d97d0b2a6 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Wed, 16 Feb 2011 15:16:57 -0500 Subject: [PATCH] In pg_upgrade, no need to initialize global struct values; they are always zeros. Also no need to free memory before we exit. --- contrib/pg_upgrade/info.c | 6 ------ contrib/pg_upgrade/pg_upgrade.c | 26 +------------------------- contrib/pg_upgrade/pg_upgrade.h | 1 - 3 files changed, 1 insertion(+), 32 deletions(-) diff --git a/contrib/pg_upgrade/info.c b/contrib/pg_upgrade/info.c index 7a5a0501f7f..0c518a2d1b4 100644 --- a/contrib/pg_upgrade/info.c +++ b/contrib/pg_upgrade/info.c @@ -22,12 +22,6 @@ static void free_rel_infos(RelInfoArr *rel_arr); 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() diff --git a/contrib/pg_upgrade/pg_upgrade.c b/contrib/pg_upgrade/pg_upgrade.c index 319ee791e1e..061544cac88 100644 --- a/contrib/pg_upgrade/pg_upgrade.c +++ b/contrib/pg_upgrade/pg_upgrade.c @@ -63,9 +63,6 @@ main(int argc, char **argv) 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); @@ -428,31 +425,10 @@ set_frozenxids(void) 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) - { + if (log_opts.fd) fclose(log_opts.fd); - log_opts.fd = NULL; - } 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 598625bcd1a..446195273c1 100644 --- a/contrib/pg_upgrade/pg_upgrade.h +++ b/contrib/pg_upgrade/pg_upgrade.h @@ -326,7 +326,6 @@ void check_loadable_libraries(void); /* 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);