From 09e836d1f68e394c99b161a274c58851eef466d4 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Thu, 31 Jul 2003 15:10:33 +0000
Subject: [PATCH] Add new function free_slurm_conf for better memory clean-up.

---
 src/common/read_config.c | 31 +++++++++++++++++++++++++++++--
 src/common/read_config.h |  6 ++++++
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/src/common/read_config.c b/src/common/read_config.c
index 76f2b7c1e68..dbf036e9d4a 100644
--- a/src/common/read_config.c
+++ b/src/common/read_config.c
@@ -87,6 +87,35 @@ getnodename (char *name, size_t len)
 	return 0;
 }
 
+/* 
+ * free_slurm_conf - free all storage associated with a slurm_ctl_conf_t.   
+ * IN/OUT ctl_conf_ptr - pointer to data structure to be freed
+ */
+void
+free_slurm_conf (slurm_ctl_conf_t *ctl_conf_ptr)
+{
+	xfree (ctl_conf_ptr->authtype);
+	xfree (ctl_conf_ptr->backup_addr);
+	xfree (ctl_conf_ptr->backup_controller);
+	xfree (ctl_conf_ptr->control_addr);
+	xfree (ctl_conf_ptr->control_machine);
+	xfree (ctl_conf_ptr->epilog);
+	xfree (ctl_conf_ptr->job_credential_private_key);
+	xfree (ctl_conf_ptr->job_credential_public_certificate);
+	xfree (ctl_conf_ptr->plugindir);
+	xfree (ctl_conf_ptr->prioritize);
+	xfree (ctl_conf_ptr->prolog);
+	xfree (ctl_conf_ptr->slurm_conf);
+	xfree (ctl_conf_ptr->slurm_user_name);
+	xfree (ctl_conf_ptr->slurmctld_logfile);
+	xfree (ctl_conf_ptr->slurmctld_pidfile);
+	xfree (ctl_conf_ptr->slurmd_logfile);
+	xfree (ctl_conf_ptr->slurmd_pidfile);
+	xfree (ctl_conf_ptr->slurmd_spooldir);
+	xfree (ctl_conf_ptr->state_save_location);
+	xfree (ctl_conf_ptr->tmp_fs);
+}
+
 
 
 /* 
@@ -132,8 +161,6 @@ init_slurm_conf (slurm_ctl_conf_t *ctl_conf_ptr)
 	xfree (ctl_conf_ptr->slurmd_spooldir);
 	ctl_conf_ptr->slurmd_timeout		= (uint16_t) NO_VAL;
 	xfree (ctl_conf_ptr->state_save_location);
-	xfree (ctl_conf_ptr->plugindir);
-	xfree (ctl_conf_ptr->authtype );
 	xfree (ctl_conf_ptr->tmp_fs);
 	ctl_conf_ptr->wait_time			= (uint16_t) NO_VAL;
 	return;
diff --git a/src/common/read_config.h b/src/common/read_config.h
index 06e10c62e14..434120dbe12 100644
--- a/src/common/read_config.h
+++ b/src/common/read_config.h
@@ -42,6 +42,12 @@
  */
 extern void init_slurm_conf (slurm_ctl_conf_t *ctl_conf_ptr);
 
+/* 
+ * free_slurm_conf - free all storage associated with a slurm_ctl_conf_t.   
+ * IN/OUT ctl_conf_ptr - pointer to data structure to be freed
+ */
+extern void free_slurm_conf (slurm_ctl_conf_t *ctl_conf_ptr);
+
 /*
  * getnodename - equivalent to gethostname(), but return only the first 
  *      component of the fully qualified name (e.g. "linux123.foo.bar" 
-- 
GitLab