Clean up leaks in t_inputrec
authorKevin Boyd <kevin44boyd@gmail.com>
Sat, 20 Mar 2021 21:43:58 +0000 (14:43 -0700)
committerJoe Jordan <ejjordan12@gmail.com>
Mon, 22 Mar 2021 07:29:09 +0000 (07:29 +0000)
Refs #3984

admin/lsan-suppressions.txt
src/gromacs/fileio/tpxio.cpp
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/gmxpreprocess/readir.cpp
src/gromacs/gmxpreprocess/readpull.cpp
src/gromacs/mdtypes/inputrec.cpp
src/gromacs/mdtypes/inputrec.h

index 07cdc82fb91dfb8316cab490c1f8790c85b3fd4c..d48a05c210003f94f31d63e22bbe9a6e54c32186 100644 (file)
@@ -13,7 +13,6 @@ leak:do_cpte_matrices
 leak:do_edsam
 leak:do_inputrec
 leak:do_single_flood
-leak:get_ir
 leak:get_zone_pulse_cgs
 leak:gmx::DomainDecompositionBuilder::Impl::build
 leak:gmx_check
@@ -37,7 +36,6 @@ leak:make_exclusions_zone
 leak:make_fep_list
 leak:make_pull_groups
 leak:make_rotation_groups
-leak:make_swap_groups
 leak:make_tables
 leak:mdoutf_write_to_trajectory_files
 # Stack trace does not report a function beyond gmx_srenew_impl, so the file is suppressed instead.
index 3d1dbb3c68bc5981c03fdc8b96ad7bb557ab2ff9..ba2c6b9783f7a140a91bd28095e892b40cabeb28 100644 (file)
@@ -447,9 +447,9 @@ static void do_simtempvals(gmx::ISerializer* serializer, t_simtemp* simtemp, int
         {
             if (serializer->reading())
             {
-                snew(simtemp->temperatures, n_lambda);
+                simtemp->temperatures.resize(n_lambda);
             }
-            serializer->doRealArray(simtemp->temperatures, n_lambda);
+            serializer->doRealArray(simtemp->temperatures.data(), n_lambda);
         }
     }
 }
index 11a7d0c551bcd4c01b436179b75c5472125941b2..a6d17f12b00899c4ffa78d123697e3149696ae13 100644 (file)
@@ -2531,6 +2531,8 @@ int gmx_grompp(int argc, char* argv[])
     sfree(opts->wall_atomtype[0]);
     sfree(opts->wall_atomtype[1]);
     sfree(opts->include);
+    sfree(opts->couple_moltype);
+
     for (auto& mol : mi)
     {
         // Some of the contents of molinfo have been stolen, so
index 6eac6098c84539f2e801768ee4aebd68cf1fc61a..2c0e08c4feef01a5307049ccbcbb18428d12aff4 100644 (file)
@@ -1696,8 +1696,7 @@ static void do_fep_params(t_inputrec* ir, gmx::ArrayRef<std::string> fep_lambda,
 
 static void do_simtemp_params(t_inputrec* ir)
 {
-
-    snew(ir->simtempvals->temperatures, ir->fepvals->n_lambda);
+    ir->simtempvals->temperatures.resize(ir->fepvals->n_lambda);
     getSimTemps(ir->fepvals->n_lambda,
                 ir->simtempvals.get(),
                 ir->fepvals->all_lambda[FreeEnergyPerturbationCouplingType::Temperature]);
index f89ff7986eb80f2daa6f75895cdfdc4a7fe495a2..5af3b4b9e6c93cd5a3eb36f20ce13b6d246b3b48 100644 (file)
@@ -373,7 +373,7 @@ std::vector<std::string> read_pullparams(std::vector<t_inpfile>* inp, pull_param
         pullCoord.eType = getEnum<PullingAlgorithm>(inp, buf, wi);
         sprintf(buf, "pull-coord%d-potential-provider", coordNum);
         setStringEntry(inp, buf, provider, "");
-        pullCoord.externalPotentialProvider = gmx_strdup(provider);
+        pullCoord.externalPotentialProvider = provider;
         sprintf(buf, "pull-coord%d-geometry", coordNum);
         pullCoord.eGeom = getEnum<PullGroupGeometry>(inp, buf, wi);
         sprintf(buf, "pull-coord%d-groups", coordNum);
index 0300c4e5d891c58625de3ed393a355a960093655..de1626255cea0fffe1f17ebc732a86dc60821151 100644 (file)
@@ -303,6 +303,21 @@ static void done_t_rot(t_rot* rot)
     sfree(rot);
 }
 
+static void done_t_swapCoords(t_swapcoords* swapCoords)
+{
+    if (swapCoords == nullptr)
+    {
+        return;
+    }
+    for (int i = 0; i < swapCoords->ngrp; i++)
+    {
+        sfree(swapCoords->grp[i].ind);
+        sfree(swapCoords->grp[i].molname);
+    }
+    sfree(swapCoords->grp);
+    sfree(swapCoords);
+}
+
 void done_inputrec(t_inputrec* ir)
 {
     sfree(ir->opts.nrdf);
@@ -320,6 +335,7 @@ void done_inputrec(t_inputrec* ir)
     sfree(ir->opts.nFreeze);
     sfree(ir->opts.egp_flags);
 
+    done_t_swapCoords(ir->swap);
     done_t_rot(ir->rot);
     delete ir->params;
 }
@@ -487,7 +503,7 @@ static void pr_simtempvals(FILE* fp, int indent, const t_simtemp* simtemp, int n
     PS("simulated-tempering-scaling", enumValueToString(simtemp->eSimTempScale));
     PR("sim-temp-low", simtemp->simtemp_low);
     PR("sim-temp-high", simtemp->simtemp_high);
-    pr_rvec(fp, indent, "simulated tempering temperatures", simtemp->temperatures, n_lambda, TRUE);
+    pr_rvec(fp, indent, "simulated tempering temperatures", simtemp->temperatures.data(), n_lambda, TRUE);
 }
 
 static void pr_expandedvals(FILE* fp, int indent, const t_expanded* expand, int n_lambda)
index 5f97a2e4edbc198be0f9085298ed73439e833e0a..c61e7c3e8a98cb22918f38a555a1c74872a4aa62 100644 (file)
@@ -109,7 +109,7 @@ struct t_simtemp
     //! The high temperature for simulated tempering
     real simtemp_high;
     //! The range of temperatures used for simulated tempering
-    real* temperatures;
+    std::vector<real> temperatures;
 };
 
 struct t_lambda