Replace most strdup with gmx_strdup
authorRoland Schulz <roland@utk.edu>
Mon, 7 Jul 2014 21:44:28 +0000 (17:44 -0400)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Thu, 31 Jul 2014 17:57:03 +0000 (19:57 +0200)
gmx_strdup existed but code was using a mixture of it and strdup.
Advantages of using gmx_strudup everywhere:
- consistency
- error handling for out of memory
- strdup might not be available (e.g. Cygwin)

Left strdup in testutils which had already error handling. And fatalerror.cpp
which cannot use gmx_strdup because it could lead to an infinite loop.

If all strdup are removed gnu++0x in gmxTestCXX11.cmake is not required
anymore.

Change-Id: I6ed3e17e34b833b01222d4b45c680db7aadada34

72 files changed:
src/gromacs/commandline/pargs.cpp
src/gromacs/essentialdynamics/edsam.c
src/gromacs/fileio/confio.c
src/gromacs/fileio/enxio.c
src/gromacs/fileio/filenm.c
src/gromacs/fileio/gmxfio.c
src/gromacs/fileio/matio.cpp
src/gromacs/fileio/strdb.c
src/gromacs/fileio/tpxio.c
src/gromacs/fileio/xvgr.cpp
src/gromacs/gmxana/gmx_anaeig.c
src/gromacs/gmxana/gmx_chi.c
src/gromacs/gmxana/gmx_clustsize.c
src/gromacs/gmxana/gmx_density.c
src/gromacs/gmxana/gmx_do_dssp.c
src/gromacs/gmxana/gmx_energy.c
src/gromacs/gmxana/gmx_genion.c
src/gromacs/gmxana/gmx_hbond.c
src/gromacs/gmxana/gmx_make_ndx.c
src/gromacs/gmxana/gmx_mindist.c
src/gromacs/gmxana/gmx_mk_angndx.c
src/gromacs/gmxana/gmx_polystat.c
src/gromacs/gmxana/gmx_rmsdist.c
src/gromacs/gmxana/gmx_saltbr.c
src/gromacs/gmxana/gmx_trjcat.c
src/gromacs/gmxana/gmx_trjconv.c
src/gromacs/gmxana/gmx_tune_pme.c
src/gromacs/gmxana/gmx_vanhove.c
src/gromacs/gmxana/gmx_wham.cpp
src/gromacs/gmxana/gmx_wheel.c
src/gromacs/gmxana/gmx_xpm2ps.c
src/gromacs/gmxana/nrama.c
src/gromacs/gmxana/nsfactor.c
src/gromacs/gmxana/sfactor.c
src/gromacs/gmxlib/readinp.c
src/gromacs/gmxpreprocess/fflibutil.cpp
src/gromacs/gmxpreprocess/genhydro.c
src/gromacs/gmxpreprocess/gmxcpp.c
src/gromacs/gmxpreprocess/h_db.c
src/gromacs/gmxpreprocess/hackblock.c
src/gromacs/gmxpreprocess/hizzie.c
src/gromacs/gmxpreprocess/nm2type.c
src/gromacs/gmxpreprocess/pdb2gmx.c
src/gromacs/gmxpreprocess/pdb2top.cpp
src/gromacs/gmxpreprocess/readir.c
src/gromacs/gmxpreprocess/resall.c
src/gromacs/gmxpreprocess/specbond.c
src/gromacs/gmxpreprocess/ter_db.c
src/gromacs/gmxpreprocess/tomorse.c
src/gromacs/gmxpreprocess/topio.c
src/gromacs/gmxpreprocess/x2top.c
src/gromacs/gmxpreprocess/xlate.c
src/gromacs/mdlib/ebin.c
src/gromacs/mdlib/mdebin.c
src/gromacs/mdlib/qm_gaussian.c
src/gromacs/mdlib/tpi.c
src/gromacs/pulling/pull.c
src/gromacs/pulling/pull_rotation.c
src/gromacs/selection/params.cpp
src/gromacs/selection/parsetree.cpp
src/gromacs/selection/scanner_internal.cpp
src/gromacs/selection/tests/toputils.cpp
src/gromacs/topology/atomprop.cpp
src/gromacs/topology/index.cpp
src/gromacs/topology/symtab.cpp
src/programs/view/buttons.cpp
src/programs/view/fgrid.cpp
src/programs/view/manager.cpp
src/programs/view/x11.cpp
src/programs/view/xdlg.cpp
src/programs/view/xdlgitem.cpp
src/programs/view/xutil.cpp

index 394205f590e047719c6e560e88adfbb02b8fffcc..8ddff6fb8c395f21f3b4f5cc7216c9b6af5d833b 100644 (file)
@@ -431,8 +431,7 @@ void OptionsAdapter::copyValues(bool bReadNode)
         snew(file->fnm->fns, file->fnm->nfiles);
         for (int i = 0; i < file->fnm->nfiles; ++i)
         {
-            // TODO: Check for out-of-memory.
-            file->fnm->fns[i] = strdup(file->values[i].c_str());
+            file->fnm->fns[i] = gmx_strdup(file->values[i].c_str());
         }
     }
     std::list<ProgramArgData>::const_iterator arg;
index 1011b04b3a7547dd2d1e06cd87bff11ca3237d14..55aceb558b3776f3c7ba14122196bb735177f70d 100644 (file)
@@ -1138,7 +1138,7 @@ static void get_flood_enx_names(t_edpar *edi, char** names, int *nnames)  /* get
     {
         srenew(names, count);
         sprintf(buf, "Vfl_%d", count);
-        names[count-1] = strdup(buf);
+        names[count-1] = gmx_strdup(buf);
         actual         = actual->next_edi;
         count++;
     }
@@ -2452,7 +2452,7 @@ static void nice_legend(const char ***setname, int *nsets, char **LegendStr, cha
     sprintf(tmp, "%c %s", EDgroupchar, value);
     add_to_string_aligned(LegendStr, tmp);
     sprintf(tmp2, "%s (%s)", tmp, unit);
-    (*setname)[*nsets] = strdup(tmp2);
+    (*setname)[*nsets] = gmx_strdup(tmp2);
     (*nsets)++;
 }
 
index 4bddce5400969d5aa43a87ac1903a08fbaf126b9..32ad75f5c798b2dde01ec1111a1b6692ee55121c 100644 (file)
@@ -256,7 +256,7 @@ int read_g96_conf(FILE *fp, const char *infile, t_trxframe *fr, char *line)
         if (fr->title == NULL)
         {
             fgets2(line, STRLEN, fp);
-            fr->title = strdup(line);
+            fr->title = gmx_strdup(line);
         }
         bEnd = FALSE;
         while (!bEnd && fgets2(line, STRLEN, fp))
index 8f164e63336e8670dbf740abd3f599cd1bd3d690..f77d26ab0b888c7964baf3be1c7962e3cdd2c319 100644 (file)
@@ -375,7 +375,7 @@ static void edr_strings(XDR *xdr, gmx_bool bRead, int file_version,
         }
         else
         {
-            nm->unit = strdup("kJ/mol");
+            nm->unit = gmx_strdup("kJ/mol");
         }
     }
 }
index 45f18226399c94e17e9b4999c84998cd9e8489dc..dad39b9f23656ff484a3c3e091dc15c121b1471f 100644 (file)
@@ -561,7 +561,7 @@ int add_suffix_to_output_names(t_filenm *fnm, int nfile, const char *suffix)
                 *extpos = '\0';
                 sprintf(newname, "%s%s.%s", buf, suffix, extpos + 1);
                 sfree(fnm[i].fns[j]);
-                fnm[i].fns[j] = strdup(newname);
+                fnm[i].fns[j] = gmx_strdup(newname);
             }
         }
     }
@@ -579,7 +579,7 @@ t_filenm *dup_tfn(int nf, const t_filenm tfn[])
         ret[i] = tfn[i]; /* just directly copy all non-string fields */
         if (tfn[i].opt)
         {
-            ret[i].opt = strdup(tfn[i].opt);
+            ret[i].opt = gmx_strdup(tfn[i].opt);
         }
         else
         {
@@ -588,7 +588,7 @@ t_filenm *dup_tfn(int nf, const t_filenm tfn[])
 
         if (tfn[i].fn)
         {
-            ret[i].fn = strdup(tfn[i].fn);
+            ret[i].fn = gmx_strdup(tfn[i].fn);
         }
         else
         {
@@ -600,7 +600,7 @@ t_filenm *dup_tfn(int nf, const t_filenm tfn[])
             snew(ret[i].fns, tfn[i].nfiles);
             for (j = 0; j < tfn[i].nfiles; j++)
             {
-                ret[i].fns[j] = strdup(tfn[i].fns[j]);
+                ret[i].fns[j] = gmx_strdup(tfn[i].fns[j]);
             }
         }
     }
index 1aed4f145a48d402f26c61219ce7638f127f0b47..20bcb378486fdb0a588bd4aa06c1fcd782f4eb64 100644 (file)
@@ -487,7 +487,7 @@ t_fileio *gmx_fio_open(const char *fn, const char *mode)
     if (fn)
     {
         fio->iFTP   = fn2ftp(fn);
-        fio->fn     = strdup(fn);
+        fio->fn     = gmx_strdup(fn);
         fio->bStdio = FALSE;
 
         /* If this file type is in the list of XDR files, open it like that */
@@ -549,7 +549,7 @@ t_fileio *gmx_fio_open(const char *fn, const char *mode)
         /* Use stdin/stdout for I/O */
         fio->iFTP   = efTPA;
         fio->fp     = bRead ? stdin : stdout;
-        fio->fn     = strdup("STDIO");
+        fio->fn     = gmx_strdup("STDIO");
         fio->bStdio = TRUE;
     }
     fio->bRead             = bRead;
index 9a223a3dfed3b6af4da8c73782b36949eb425dde..94007d1216d248c7a2202285e6e807ca8201dfb3 100644 (file)
@@ -143,7 +143,7 @@ int getcmap(FILE *in, const char *fn, t_mapping **map)
         sscanf(line, "%s%s%lf%lf%lf", code, desc, &r, &g, &b);
         m[i].code.c1 = code[0];
         m[i].code.c2 = 0;
-        m[i].desc    = strdup(desc);
+        m[i].desc    = gmx_strdup(desc);
         m[i].rgb.r   = r;
         m[i].rgb.g   = g;
         m[i].rgb.b   = b;
@@ -423,7 +423,7 @@ static void read_xpm_entry(FILE *in, t_matrix *mm)
             line = strchr(line, '\"');
             line++;
             line2string(&line);
-            map[m].desc = strdup(line);
+            map[m].desc = gmx_strdup(line);
             m++;
         }
     }
index 3ceca94be87270483ffffbefada9c4b2406c3e0f..b8811a5fb41638e7730a78060556408da4b0c16b 100644 (file)
@@ -143,7 +143,7 @@ int get_strings(const char *db, char ***strings)
 #ifdef DEBUG
         fprintf(stderr, "Have read: %s\n", buf);
 #endif
-        ptr[i] = strdup(buf);
+        ptr[i] = gmx_strdup(buf);
     }
     gmx_ffclose(in);
 
@@ -224,7 +224,7 @@ int get_file(const char *db, char ***strings)
             maxi += 50;
             srenew(ptr, maxi);
         }
-        ptr[i] = strdup(buf);
+        ptr[i] = gmx_strdup(buf);
         i++;
     }
     nstr = i;
index 96c948f9a6d7a803b5a59690924f0bfe1938f50f..5004a8666432a796b50f7a8692729bba457946aa 100644 (file)
@@ -2723,7 +2723,7 @@ static void do_symtab(t_fileio *fio, t_symtab *symtab, gmx_bool bRead)
         for (i = 0; (i < nr); i++)
         {
             gmx_fio_do_string(fio, buf);
-            symbuf->buf[i] = strdup(buf);
+            symbuf->buf[i] = gmx_strdup(buf);
         }
     }
     else
index d8a4e729a3dad822b4acabb1b6abd66831a97611..dddc4afc895fb14c135722bdf97bfb949cd1e339 100644 (file)
@@ -534,17 +534,17 @@ static char *read_xvgr_string(const char *line)
         ptr1 = strchr(ptr0, '"');
         if (ptr1 != NULL)
         {
-            str            = strdup(ptr0);
+            str            = gmx_strdup(ptr0);
             str[ptr1-ptr0] = '\0';
         }
         else
         {
-            str = strdup("");
+            str = gmx_strdup("");
         }
     }
     else
     {
-        str = strdup("");
+        str = gmx_strdup("");
     }
 
     return str;
index eb1d28e6b685227f9c98e1fae6363c628d982c8f..6cef5adfeae9d6d1cc5a904c06f7c813a2e9e7a2 100644 (file)
@@ -646,7 +646,7 @@ static void project(const char *trajfile, t_topology *top, int ePBC, matrix topb
         for (v = 0; v < noutvec; v++)
         {
             sprintf(str, "vec %d", eignr[outvec[v]]+1);
-            ylabel[v] = strdup(str);
+            ylabel[v] = gmx_strdup(str);
         }
         sprintf(str, "projection on eigenvectors (%s)", proj_unit);
         write_xvgr_graphs(projfile, noutvec, 1, str, NULL, output_env_get_xvgr_tlabel(oenv),
@@ -712,8 +712,8 @@ static void project(const char *trajfile, t_topology *top, int ePBC, matrix topb
         init_t_atoms(&atoms, nframes, FALSE);
         snew(x, nframes);
         snew(b, nframes);
-        atnm  = strdup("C");
-        resnm = strdup("PRJ");
+        atnm  = gmx_strdup("C");
+        resnm = gmx_strdup("PRJ");
 
         if (nframes > 10000)
         {
@@ -878,7 +878,7 @@ static void components(const char *outfile, int natoms,
     {
         v = outvec[g];
         sprintf(str, "vec %d", eignr[v]+1);
-        ylabel[g] = strdup(str);
+        ylabel[g] = gmx_strdup(str);
         snew(y[g], 4);
         for (s = 0; s < 4; s++)
         {
@@ -935,7 +935,7 @@ static void rmsf(const char *outfile, int natoms, real *sqrtm,
             gmx_fatal(FARGS, "Selected vector %d is larger than the number of eigenvalues (%d)", eignr[v]+1, neig);
         }
         sprintf(str, "vec %d", eignr[v]+1);
-        ylabel[g] = strdup(str);
+        ylabel[g] = gmx_strdup(str);
         snew(y[g], natoms);
         for (i = 0; i < natoms; i++)
         {
index f95e495f10556bf51f1df1bb99de0ab1b5415b84..031e7e7ee02ccef3d307e6a936d13a06368ebdaf 100644 (file)
@@ -681,15 +681,15 @@ static void histogramming(FILE *log, int nbin, gmx_residuetype_t *rt,
         snew(leg, NJC);
         for (i = 0; (i < NKKKPHI); i++)
         {
-            leg[i] = strdup(kkkphi[i].name);
+            leg[i] = gmx_strdup(kkkphi[i].name);
         }
         for (i = 0; (i < NKKKPSI); i++)
         {
-            leg[i+NKKKPHI] = strdup(kkkpsi[i].name);
+            leg[i+NKKKPHI] = gmx_strdup(kkkpsi[i].name);
         }
         for (i = 0; (i < NKKKCHI); i++)
         {
-            leg[i+NKKKPHI+NKKKPSI] = strdup(kkkchi1[i].name);
+            leg[i+NKKKPHI+NKKKPSI] = gmx_strdup(kkkchi1[i].name);
         }
         xvgr_legend(fp, NJC, (const char**)leg, oenv);
         fprintf(fp, "%5s ", "#Res.");
@@ -1018,15 +1018,15 @@ static void print_transitions(const char *fn, int maxchi, int nlist,
     char *leg[edMax];
 #define NLEG asize(leg)
 
-    leg[0] = strdup("Phi");
-    leg[1] = strdup("Psi");
-    leg[2] = strdup("Omega");
-    leg[3] = strdup("Chi1");
-    leg[4] = strdup("Chi2");
-    leg[5] = strdup("Chi3");
-    leg[6] = strdup("Chi4");
-    leg[7] = strdup("Chi5");
-    leg[8] = strdup("Chi6");
+    leg[0] = gmx_strdup("Phi");
+    leg[1] = gmx_strdup("Psi");
+    leg[2] = gmx_strdup("Omega");
+    leg[3] = gmx_strdup("Chi1");
+    leg[4] = gmx_strdup("Chi2");
+    leg[5] = gmx_strdup("Chi3");
+    leg[6] = gmx_strdup("Chi4");
+    leg[7] = gmx_strdup("Chi5");
+    leg[8] = gmx_strdup("Chi6");
 
     /* Print order parameters */
     fp = xvgropen(fn, "Dihedral Rotamer Transitions", "Residue", "Transitions/ns",
@@ -1082,7 +1082,7 @@ static void order_params(FILE *log,
 
     for (i = 0; i < NLEG; i++)
     {
-        leg[i] = strdup(const_leg[i]);
+        leg[i] = gmx_strdup(const_leg[i]);
     }
 
     /* Print order parameters */
index 787aeb89104e01019dbd33d1b2a58d686dc55aba..ad1ee19258941627c9bc54842edddf73493b9164 100644 (file)
@@ -147,7 +147,7 @@ static void clust_size(const char *ndx, const char *trx, const char *xpm,
         {
             index[i] = i;
         }
-        gname = strdup("mols");
+        gname = gmx_strdup("mols");
     }
     else
     {
index ab0ee0b7e05958df2d3e7af942f0cec1e998d12a..a0caf03c6d8a85d28a14ddf49cb9a5a2bf0b9828 100644 (file)
@@ -119,7 +119,7 @@ int get_electrons(t_electron **eltab, const char *fn)
             gmx_fatal(FARGS, "Invalid line in datafile at line %d\n", i+1);
         }
         (*eltab)[i].nr_el    = tempnr;
-        (*eltab)[i].atomname = strdup(tempname);
+        (*eltab)[i].atomname = gmx_strdup(tempname);
     }
     gmx_ffclose(in);
 
@@ -275,7 +275,7 @@ void calc_electron_density(const char *fn, atom_id **index, int gnx[],
                     slice = (z / (*slWidth));
                 }
                 sought.nr_el    = 0;
-                sought.atomname = strdup(*(top->atoms.atomname[index[n][i]]));
+                sought.atomname = gmx_strdup(*(top->atoms.atomname[index[n][i]]));
 
                 /* now find the number of electrons. This is not efficient. */
                 found = (t_electron *)
index d5642b1b7ebc411f4316b4b7182277061efb00f3..74fd34c1c10aeed1b770016c0b7d451f315fefb3 100644 (file)
@@ -212,7 +212,7 @@ static void check_oo(t_atoms *atoms)
 
     int   i;
 
-    OOO = strdup("O");
+    OOO = gmx_strdup("O");
 
     for (i = 0; (i < atoms->nr); i++)
     {
@@ -352,7 +352,7 @@ void analyse_ss(const char *outfile, t_matrix *mat, const char *ss_string,
     leg[0] = "Structure";
     for (s = 0; s < (size_t)mat->nmap; s++)
     {
-        leg[s+1] = strdup(map[s].desc);
+        leg[s+1] = gmx_strdup(map[s].desc);
     }
 
     fp = xvgropen(outfile, "Secondary Structure",
index 177f4f596b12b0099d8905b4202ee4e8b2458d35..d120708e24883306b315f6d49e4dc8c951724ae6 100644 (file)
@@ -191,7 +191,7 @@ static int *select_by_name(int nre, gmx_enxnm_t *nm, int *nset)
     j = 0;
     for (k = 0; k < nre; k++)
     {
-        newnm[k] = strdup(nm[k].name);
+        newnm[k] = gmx_strdup(nm[k].name);
         /* Insert dashes in all the names */
         while ((ptr = strchr(newnm[k], ' ')) != NULL)
         {
@@ -2144,7 +2144,7 @@ int gmx_energy(int argc, char *argv[])
         }
         if (bSum)
         {
-            leg[nset] = strdup("Sum");
+            leg[nset] = gmx_strdup("Sum");
             xvgr_legend(out, nset+1, (const char**)leg, oenv);
         }
         else
@@ -2281,14 +2281,14 @@ int gmx_energy(int argc, char *argv[])
                 for (j = 0; j < 3; j++)
                 {
                     sprintf(buf, "eig%d", j+1);
-                    otenleg[(bOvec ? 12 : 3)*i+j] = strdup(buf);
+                    otenleg[(bOvec ? 12 : 3)*i+j] = gmx_strdup(buf);
                 }
                 if (bOvec)
                 {
                     for (j = 0; j < 9; j++)
                     {
                         sprintf(buf, "vec%d%s", j/3+1, j%3 == 0 ? "x" : (j%3 == 1 ? "y" : "z"));
-                        otenleg[12*i+3+j] = strdup(buf);
+                        otenleg[12*i+3+j] = gmx_strdup(buf);
                     }
                 }
             }
index 8558fe866fe85c1fa43caf304b2faabd25a81522..64d0a98ff60fc8920b872dcc57bc5e55881e3a55 100644 (file)
@@ -122,7 +122,7 @@ static char *aname(const char *mname)
     char *str;
     int   i;
 
-    str = strdup(mname);
+    str = gmx_strdup(mname);
     i   = strlen(str)-1;
     while (i > 1 && (isdigit(str[i]) || (str[i] == '+') || (str[i] == '-')))
     {
@@ -176,14 +176,14 @@ void sort_ions(int nsa, int nw, int repl[], atom_id index[],
         if (np)
         {
             snew(pptr, 1);
-            pptr[0] = strdup(p_name);
+            pptr[0] = gmx_strdup(p_name);
             snew(paptr, 1);
             paptr[0] = aname(p_name);
         }
         if (nn)
         {
             snew(nptr, 1);
-            nptr[0] = strdup(n_name);
+            nptr[0] = gmx_strdup(n_name);
             snew(naptr, 1);
             naptr[0] = aname(n_name);
         }
@@ -290,7 +290,7 @@ static void update_topol(const char *topinout, int p_num, int n_num,
             }
             /* Store this molecules section line */
             srenew(mol_line, nmol_line+1);
-            mol_line[nmol_line] = strdup(buf);
+            mol_line[nmol_line] = gmx_strdup(buf);
             nmol_line++;
         }
     }
index 52f5ec6ca0b11b51c9c6d52d5c0b9ead16c6dfb2..07228ef4b1725a339bcf9509e955ef737b14a5bc 100644 (file)
@@ -4605,7 +4605,7 @@ int gmx_hbond(int argc, char *argv[])
                     gmx_fatal(FARGS, "Could not initiate t_gemParams params.");
                 }
             }
-            gemstring = strdup(gemType[hb->per->gemtype]);
+            gemstring = gmx_strdup(gemType[hb->per->gemtype]);
             do_hbac(opt2fn("-ac", NFILE, fnm), hb, nDump,
                     bMerge, bContact, fit_start, temp, r2cut > 0, smooth_tail_start, oenv,
                     gemstring, nThreads, NN, bBallistic, bGemFit);
@@ -4745,9 +4745,9 @@ int gmx_hbond(int argc, char *argv[])
             if (USE_THIS_GROUP(j) )
             {
                 sprintf(buf, "Donors %s", grpnames[j]);
-                legnames[i++] = strdup(buf);
+                legnames[i++] = gmx_strdup(buf);
                 sprintf(buf, "Acceptors %s", grpnames[j]);
-                legnames[i++] = strdup(buf);
+                legnames[i++] = gmx_strdup(buf);
             }
         }
         if (i != nleg)
index cafeb6c7f3785de26377c34c7b08b2f073f32228..6d1aba949c3c244f656f127dcac3c9d6d376561d 100644 (file)
@@ -278,7 +278,7 @@ static gmx_bool parse_string(char **string, int *nr, int ngrps, char **grpname)
     {
         c = (*string)[0];
         (*string)++;
-        s  = strdup((*string));
+        s  = gmx_strdup((*string));
         sp = strchr(s, c);
         if (sp != NULL)
         {
@@ -747,7 +747,7 @@ static void remove_group(int nr, int nr2, t_blocka *block, char ***gn)
             {
                 block->index[i] = block->index[i+1]-shift;
             }
-            name = strdup((*gn)[nr]);
+            name = gmx_strdup((*gn)[nr]);
             sfree((*gn)[nr]);
             for (i = nr; i < block->nr-1; i++)
             {
@@ -796,7 +796,7 @@ static void split_group(t_atoms *atoms, int sel_nr, t_blocka *block, char ***gn,
             {
                 sprintf(buf, "%s_%s_%d", (*gn)[sel_nr], name, atoms->resinfo[resind].nr);
             }
-            (*gn)[block->nr-1] = strdup(buf);
+            (*gn)[block->nr-1] = gmx_strdup(buf);
         }
         block->a[block->nra] = a;
         block->nra++;
@@ -887,7 +887,7 @@ static int split_chain(t_atoms *atoms, rvec *x,
             srenew(block->index, block->nr+1);
             srenew(*gn, block->nr);
             sprintf(buf, "%s_chain%d", (*gn)[sel_nr], j+1);
-            (*gn)[block->nr-1] = strdup(buf);
+            (*gn)[block->nr-1] = gmx_strdup(buf);
             for (i = block->index[sel_nr]; i < block->index[sel_nr+1]; i++)
             {
                 a = block->a[i];
@@ -1330,7 +1330,7 @@ static void edit_index(int natoms, t_atoms *atoms, rvec *x, t_blocka *block, cha
                 {
                     sscanf(string, "%s", gname);
                     sfree((*gn)[sel_nr]);
-                    (*gn)[sel_nr] = strdup(gname);
+                    (*gn)[sel_nr] = gmx_strdup(gname);
                 }
             }
         }
@@ -1448,7 +1448,7 @@ static void edit_index(int natoms, t_atoms *atoms, rvec *x, t_blocka *block, cha
                 copy2block(nr, index, block);
                 srenew(*gn, block->nr);
                 newgroup        = block->nr-1;
-                (*gn)[newgroup] = strdup(gname);
+                (*gn)[newgroup] = gmx_strdup(gname);
             }
             else
             {
index 439d19c9d4498550e9863ee20bf87e42283b17b0..63571011f4d77e3c75655d870503ed5420b37537 100644 (file)
@@ -361,7 +361,7 @@ void dist_plot(const char *fn, const char *afile, const char *dfile,
         {
             snew(leg, 1);
             sprintf(buf, "Internal in %s", grpn[0]);
-            leg[0] = strdup(buf);
+            leg[0] = gmx_strdup(buf);
             xvgr_legend(dist, 0, (const char**)leg, oenv);
             if (num)
             {
@@ -376,7 +376,7 @@ void dist_plot(const char *fn, const char *afile, const char *dfile,
                 for (k = i+1; (k < ng); k++, j++)
                 {
                     sprintf(buf, "%s-%s", grpn[i], grpn[k]);
-                    leg[j] = strdup(buf);
+                    leg[j] = gmx_strdup(buf);
                 }
             }
             xvgr_legend(dist, j, (const char**)leg, oenv);
@@ -392,7 +392,7 @@ void dist_plot(const char *fn, const char *afile, const char *dfile,
         for (i = 0; (i < ng-1); i++)
         {
             sprintf(buf, "%s-%s", grpn[0], grpn[i+1]);
-            leg[i] = strdup(buf);
+            leg[i] = gmx_strdup(buf);
         }
         xvgr_legend(dist, ng-1, (const char**)leg, oenv);
         if (num)
index 89d60d6509b9dc0d8353d83cfda48ef110e9068a..9a52867969b93959806e43f6be09aaef461c7b75 100644 (file)
@@ -129,7 +129,7 @@ static void fill_ft_ind(int nft, int *ft, t_idef *idef,
                         gmx_fatal(FARGS, "Unsupported function type '%s' selected",
                                   interaction_function[ftype].longname);
                 }
-                grpnames[ind] = strdup(buf);
+                grpnames[ind] = gmx_strdup(buf);
                 ind++;
             }
         }
index 3595fc9eef12e9a32cadcdeb72d6bbba21ba64c6..bed77c36da75e6f7f5cbdc5da0b0597a40bbfb01 100644 (file)
@@ -233,7 +233,7 @@ int gmx_polystat(int argc, char *argv[])
             for (d2 = 0; d2 < DIM; d2++)
             {
                 sprintf(buf, "eig%d %c", d+1, 'x'+d2);
-                legp[d*DIM+d2] = strdup(buf);
+                legp[d*DIM+d2] = gmx_strdup(buf);
             }
         }
         xvgr_legend(outv, DIM*DIM, (const char**)legp, oenv);
index f3e1038fd1dc5b53c08c3a0ac195570daac3e78d..e5983aa36fdc066261fd1e38432c232912899203 100644 (file)
@@ -186,14 +186,14 @@ static int read_equiv(const char *eq_fn, t_equiv ***equivptr)
         {
             lp += n;
             snew(equiv[neq], 1);
-            equiv[neq][0].nname = strdup(atomname);
+            equiv[neq][0].nname = gmx_strdup(atomname);
             while (sscanf(lp, "%d %s %s %n", &resnr, resname, atomname, &n) == 3)
             {
                 /* this is not efficient, but I'm lazy (again) */
                 srenew(equiv[neq], na+1);
                 equiv[neq][na].rnr   = resnr-1;
-                equiv[neq][na].rname = strdup(resname);
-                equiv[neq][na].aname = strdup(atomname);
+                equiv[neq][na].rname = gmx_strdup(resname);
+                equiv[neq][na].aname = gmx_strdup(atomname);
                 if (na > 0)
                 {
                     equiv[neq][na].nname = NULL;
@@ -267,7 +267,7 @@ static gmx_bool is_equiv(int neq, t_equiv **equiv, char **nname,
     }
     if (bFound)
     {
-        *nname = strdup(equiv[i-1][0].nname);
+        *nname = gmx_strdup(equiv[i-1][0].nname);
     }
 
     return bFound;
@@ -318,7 +318,7 @@ static int analyze_noe_equivalent(const char *eq_fn,
                                  rnrj, *atoms->resinfo[rnrj].name, *atoms->atomname[index[j]]);
                     if (nnm[i] && bEquiv)
                     {
-                        nnm[j] = strdup(nnm[i]);
+                        nnm[j] = gmx_strdup(nnm[i]);
                     }
                     if (bEquiv)
                     {
@@ -399,18 +399,18 @@ static int analyze_noe_equivalent(const char *eq_fn,
             noe_gr[gi].anr  = index[i];
             if (nnm[i])
             {
-                noe_gr[gi].aname = strdup(nnm[i]);
+                noe_gr[gi].aname = gmx_strdup(nnm[i]);
             }
             else
             {
-                noe_gr[gi].aname = strdup(*atoms->atomname[index[i]]);
+                noe_gr[gi].aname = gmx_strdup(*atoms->atomname[index[i]]);
                 if (noe_index[i] == noe_index[i+1])
                 {
                     noe_gr[gi].aname[strlen(noe_gr[gi].aname)-1] = '*';
                 }
             }
             noe_gr[gi].rnr   = atoms->atom[index[i]].resind;
-            noe_gr[gi].rname = strdup(*atoms->resinfo[noe_gr[gi].rnr].name);
+            noe_gr[gi].rname = gmx_strdup(*atoms->resinfo[noe_gr[gi].rnr].name);
             /* dump group definitions */
             if (debug)
             {
index adca73302df3404142246c038155f14f02140e6c..46f1c59731f9aae546de5fc934675e46043c1e48 100644 (file)
@@ -86,7 +86,7 @@ static t_charge *mk_charge(t_atoms *atoms, t_block *cgs, int *nncg)
                     *(atoms->resinfo[resnr].name),
                     atoms->resinfo[resnr].nr,
                     anr+1);
-            cg[ncg].label = strdup(buf);
+            cg[ncg].label = gmx_strdup(buf);
             ncg++;
         }
     }
index 9ad5e3fd3be42c7b02521fefddd2dbabe54c3cd7..90bbb779c91a82051d34a4a9dbc8e8d87c58df0e 100644 (file)
@@ -587,7 +587,7 @@ int gmx_trjcat(int argc, char *argv[])
     {
         if (nfile_out != nset)
         {
-            char *buf = strdup(fnms_out[0]);
+            char *buf = gmx_strdup(fnms_out[0]);
             snew(fnms_out, nset);
             for (i = 0; (i < nset); i++)
             {
index dcb57c94f1b62d98cb351ee44fc4a88891e09247..d37df65a535e4cb9b8e286f73bbed4fd4cecaacd 100644 (file)
@@ -1043,7 +1043,7 @@ int gmx_trjconv(int argc, char *argv[])
             {
                 gmx_fatal(FARGS, "Output file name '%s' does not contain a '.'", out_file);
             }
-            outf_base = strdup(out_file);
+            outf_base = gmx_strdup(out_file);
             outf_base[outf_ext - out_file] = '\0';
         }
 
index 3e4f1712f7a8e9e21dd685f4f09b58b00b064e4a..d93d597b0e29675bafbf70e171a839ccbbf564ae 100644 (file)
@@ -592,25 +592,25 @@ static void get_program_paths(gmx_bool bThreads, char *cmd_mpirun[], char *cmd_m
     {
         if ( (cp = getenv("MPIRUN")) != NULL)
         {
-            *cmd_mpirun = strdup(cp);
+            *cmd_mpirun = gmx_strdup(cp);
         }
         else
         {
-            *cmd_mpirun = strdup(def_mpirun);
+            *cmd_mpirun = gmx_strdup(def_mpirun);
         }
     }
     else
     {
-        *cmd_mpirun = strdup(empty_mpirun);
+        *cmd_mpirun = gmx_strdup(empty_mpirun);
     }
 
     if ( (cp = getenv("MDRUN" )) != NULL)
     {
-        *cmd_mdrun  = strdup(cp);
+        *cmd_mdrun  = gmx_strdup(cp);
     }
     else
     {
-        *cmd_mdrun  = strdup(def_mdrun);
+        *cmd_mdrun  = gmx_strdup(def_mdrun);
     }
 }
 
index 253027e0cb3b4644040907f55cafd40b9ad02d8a..4aa720fdebe15410f5d5873325bedd90664c5832 100644 (file)
@@ -443,7 +443,7 @@ int gmx_vanhove(int argc, char *argv[])
         for (fbin = 0; fbin < nr; fbin++)
         {
             sprintf(buf, "%g ps", (fbin + 1)*fshift*dt);
-            legend[fbin] = strdup(buf);
+            legend[fbin] = gmx_strdup(buf);
         }
         xvgr_legend(fp, nr, (const char**)legend, oenv);
         for (i = 0; i < nalloc; i++)
index a37f2ca50359d7e137e9eff6aed3f1f590e0f422..7a0240a4a28116b662d6e02ed3b25298c2d51ad3 100644 (file)
@@ -1453,7 +1453,7 @@ void print_histograms(const char *fnhist, t_UmbrellaWindow * window, int nWindow
     }
     else
     {
-        fn = strdup(fnhist);
+        fn = gmx_strdup(fnhist);
         strcpy(title, "Umbrella histograms");
     }
 
index 170c668cb7401fc0fd30460a27904cc7a27752ed..d518991015b2314d4088b8f85b909af5570d7950 100644 (file)
@@ -50,6 +50,7 @@
 #include "gmx_ana.h"
 
 #include "gromacs/commandline/pargs.h"
+#include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/futil.h"
 #include "gromacs/fileio/strdb.h"
 #include "gromacs/fileio/writeps.h"
@@ -264,7 +265,7 @@ int gmx_wheel(int argc, char *argv[])
         }
         else if (strcmp(argv[i], "-T") == 0)
         {
-            title = strdup(argv[++i]);
+            title = gmx_strdup(argv[++i]);
             fprintf(stderr, "Title will be '%s'\n", title);
         }
         else if (strcmp(argv[i], "-nn") == 0)
index 449a1b792caea891eb77d599bd366464f8a30cdb..caca09b2b7a7d3020652e06c76dd1240b8831934 100644 (file)
@@ -398,7 +398,7 @@ static void draw_boxes(t_psdata ps, real x0, real y0, real w,
         for (j = 0; (j < ntx); j++)
         {
             sprintf(buf, "%g", mat[i].axis_x[j]);
-            xtick[j] = strdup(buf);
+            xtick[j] = gmx_strdup(buf);
         }
         ps_strfont(ps, psr->X.tickfont, psr->X.tickfontsize);
         for (x = 0; (x < ntx); x++)
@@ -435,7 +435,7 @@ static void draw_boxes(t_psdata ps, real x0, real y0, real w,
         for (j = 0; (j < nty); j++)
         {
             sprintf(buf, "%g", mat[i].axis_y[j]);
-            ytick[j] = strdup(buf);
+            ytick[j] = gmx_strdup(buf);
         }
 
         for (y = 0; (y < nty); y++)
index db6e0d75101386e2c70b5c44fe3a03a8d7988802..c977418324fe0e09bba9fb99b7a78125529e4b35 100644 (file)
@@ -142,7 +142,7 @@ static void add_xr(t_xrama *xr, int ff[5], t_atoms *atoms)
     xr->pp[xr->npp].bShow = FALSE;
     sprintf(buf, "%s-%d", *atoms->resinfo[atoms->atom[ff[1]].resind].name,
             atoms->resinfo[atoms->atom[ff[1]].resind].nr);
-    xr->pp[xr->npp].label = strdup(buf);
+    xr->pp[xr->npp].label = gmx_strdup(buf);
     xr->npp++;
 }
 
index d53a162fa8b414d8555575bd5af8c696aebd2487..c8e70dd921cd2fc5ef11f8c2931ab7f605feef27 100644 (file)
@@ -115,7 +115,7 @@ gmx_neutron_atomic_structurefactors_t *gmx_neutronstructurefactors_init(const ch
         i = line_no;
         if (sscanf(line, "%s %d %d %lf", atomnm, &p, &n, &slength) == 4)
         {
-            gnsf->atomnm[i]  = strdup(atomnm);
+            gnsf->atomnm[i]  = gmx_strdup(atomnm);
             gnsf->n[i]       = n;
             gnsf->p[i]       = p;
             gnsf->slength[i] = slength;
index a074fbc1b0177e509f3bd171e8037ca9c1d1b88e..5da3cfcb2e76811dbd51ab2e396e0e8b01927020 100644 (file)
@@ -282,7 +282,7 @@ extern gmx_structurefactors_t *gmx_structurefactors_init(const char *datfn)
         if (sscanf(line, "%s %d %lf %lf %lf %lf %lf %lf %lf %lf %lf",
                    atomn, &p, &a1, &a2, &a3, &a4, &b1, &b2, &b3, &b4, &c) == 11)
         {
-            gsf->atomnm[i] = strdup(atomn);
+            gsf->atomnm[i] = gmx_strdup(atomn);
             gsf->p[i]      = p;
             snew(gsf->a[i], 4);
             snew(gsf->b[i], 4);
index da6b014de9a71c88a759d1d6498c7f967596e2d8..5e4dfc9c106616a4be56faeddb9410cb8e3973b7 100644 (file)
@@ -168,8 +168,8 @@ t_inpfile *read_inpfile(const char *fn, int *ninp,
                                 inp[nin-1].count      = 0;
                                 inp[nin-1].bObsolete  = FALSE;
                                 inp[nin-1].bSet       = FALSE;
-                                inp[nin-1].name       = strdup(lbuf);
-                                inp[nin-1].value      = strdup(rbuf);
+                                inp[nin-1].name       = gmx_strdup(lbuf);
+                                inp[nin-1].value      = gmx_strdup(rbuf);
                             }
                             else
                             {
@@ -184,7 +184,7 @@ t_inpfile *read_inpfile(const char *fn, int *ninp,
                                 {
                                     /* override */
                                     sfree(inp[found_index].value);
-                                    inp[found_index].value = strdup(rbuf);
+                                    inp[found_index].value = gmx_strdup(rbuf);
                                     sprintf(warn_buf,
                                             "Overriding existing parameter \"%s\" with value \"%s\"\n",
                                             lbuf, rbuf);
@@ -294,7 +294,7 @@ void replace_inp_entry(int ninp, t_inpfile *inp, const char *old_entry, const ch
                 fprintf(stderr, "Replacing old mdp entry '%s' by '%s'\n",
                         inp[i].name, new_entry);
                 sfree(inp[i].name);
-                inp[i].name = strdup(new_entry);
+                inp[i].name = gmx_strdup(new_entry);
             }
             else
             {
@@ -342,7 +342,7 @@ static int get_einp(int *ninp, t_inpfile **inp, const char *name)
         notfound = TRUE;
         i        = (*ninp)++;
         srenew(*inp, (*ninp));
-        (*inp)[i].name = strdup(name);
+        (*inp)[i].name = gmx_strdup(name);
         (*inp)[i].bSet = TRUE;
     }
     (*inp)[i].count = (*inp)[0].inp_count++;
@@ -375,7 +375,7 @@ int get_eint(int *ninp, t_inpfile **inp, const char *name, int def,
     if (ii == -1)
     {
         sprintf(buf, "%d", def);
-        (*inp)[(*ninp)-1].value = strdup(buf);
+        (*inp)[(*ninp)-1].value = gmx_strdup(buf);
 
         return def;
     }
@@ -405,7 +405,7 @@ gmx_int64_t get_eint64(int *ninp, t_inpfile **inp,
     if (ii == -1)
     {
         sprintf(buf, "%"GMX_PRId64, def);
-        (*inp)[(*ninp)-1].value = strdup(buf);
+        (*inp)[(*ninp)-1].value = gmx_strdup(buf);
 
         return def;
     }
@@ -434,7 +434,7 @@ double get_ereal(int *ninp, t_inpfile **inp, const char *name, double def,
     if (ii == -1)
     {
         sprintf(buf, "%g", def);
-        (*inp)[(*ninp)-1].value = strdup(buf);
+        (*inp)[(*ninp)-1].value = gmx_strdup(buf);
 
         return def;
     }
@@ -463,7 +463,7 @@ const char *get_estr(int *ninp, t_inpfile **inp, const char *name, const char *d
         if (def)
         {
             sprintf(buf, "%s", def);
-            (*inp)[(*ninp)-1].value = strdup(buf);
+            (*inp)[(*ninp)-1].value = gmx_strdup(buf);
         }
         else
         {
@@ -489,7 +489,7 @@ int get_eeenum(int *ninp, t_inpfile **inp, const char *name, const char **defs,
 
     if (ii == -1)
     {
-        (*inp)[(*ninp)-1].value = strdup(defs[0]);
+        (*inp)[(*ninp)-1].value = gmx_strdup(defs[0]);
 
         return 0;
     }
@@ -522,7 +522,7 @@ int get_eeenum(int *ninp, t_inpfile **inp, const char *name, const char **defs,
             fprintf(stderr, "%s\n", buf);
         }
 
-        (*inp)[ii].value = strdup(defs[0]);
+        (*inp)[ii].value = gmx_strdup(defs[0]);
 
         return 0;
     }
index 1c2d368216ed2b1bf6568bd3100d6710dce42f2e..c2cbdf488cea41eaf8bb2abfec65b6acc6cd3aad 100644 (file)
@@ -200,7 +200,7 @@ static int low_fflib_search_file_end(const char *ffdir,
                         sprintf(fn_dir, "%s%c%s", dir, DIR_SEPARATOR, nextname);
 
                         /* Copy the file name, possibly including the path. */
-                        fns[n] = strdup(fn_dir);
+                        fns[n] = gmx_strdup(fn_dir);
 
                         if (ffdir == NULL)
                         {
@@ -213,11 +213,11 @@ static int low_fflib_search_file_end(const char *ffdir,
                             srenew(fns_short, n+1);
                             if (strcmp(dir, ".") == 0 || bEnvIsSet)
                             {
-                                fns_short[n] = strdup(fn_dir);
+                                fns_short[n] = gmx_strdup(fn_dir);
                             }
                             else
                             {
-                                fns_short[n] = strdup(nextname);
+                                fns_short[n] = gmx_strdup(nextname);
                             }
                         }
                         n++;
@@ -293,7 +293,7 @@ int fflib_search_file_in_dirend(const char *filename, const char *dirend,
                 {
                     /* We have a match */
                     srenew(dns, n+1);
-                    dns[n] = strdup(f_short[i]);
+                    dns[n] = gmx_strdup(f_short[i]);
                     n++;
                 }
             }
index 238a3db4806d1f3e7fc9f3d3d8a0c626678c899d..4ca92aa37387857e4753b5bba8d528e7ce5a5223 100644 (file)
@@ -52,6 +52,7 @@
 #include "network.h"
 
 #include "gromacs/topology/symtab.h"
+#include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/smalloc.h"
 
@@ -59,7 +60,7 @@ static void copy_atom(t_atoms *atoms1, int a1, t_atoms *atoms2, int a2)
 {
     atoms2->atom[a2] = atoms1->atom[a1];
     snew(atoms2->atomname[a2], 1);
-    *atoms2->atomname[a2] = strdup(*atoms1->atomname[a1]);
+    *atoms2->atomname[a2] = gmx_strdup(*atoms1->atomname[a1]);
 }
 
 static atom_id pdbasearch_atom(const char *name, int resind, t_atoms *pdba,
@@ -165,7 +166,7 @@ static t_hackblock *get_hackblocks(t_atoms *pdba, int nah, t_hackblock ah[],
         {
             if (hb[rnr].name == NULL)
             {
-                hb[rnr].name = strdup(ahptr->name);
+                hb[rnr].name = gmx_strdup(ahptr->name);
             }
             merge_hacks(ahptr, &hb[rnr]);
         }
@@ -230,7 +231,7 @@ static void expand_hackblocks_one(t_hackblock *hbr, char *atomname,
                 {
                     if ( (*abi)[*nabi + k].oname == NULL)
                     {
-                        (*abi)[*nabi + k].nname    = strdup(atomname);
+                        (*abi)[*nabi + k].nname    = gmx_strdup(atomname);
                         (*abi)[*nabi + k].nname[0] = 'H';
                     }
                 }
@@ -244,7 +245,7 @@ static void expand_hackblocks_one(t_hackblock *hbr, char *atomname,
                                 (*abi)[*nabi + k].oname ? (*abi)[*nabi + k].oname : "");
                     }
                     sfree((*abi)[*nabi + k].nname);
-                    (*abi)[*nabi + k].nname = strdup(hbr->hack[j].nname);
+                    (*abi)[*nabi + k].nname = gmx_strdup(hbr->hack[j].nname);
                 }
 
                 if (hbr->hack[j].tp == 10 && k == 2)
@@ -665,7 +666,7 @@ static int add_h_low(t_atoms **pdbaptr, rvec *xptr[],
                                         ab[i][j].nname);
                             }
                             snew(newpdba->atomname[newi], 1);
-                            *newpdba->atomname[newi] = strdup(ab[i][j].nname);
+                            *newpdba->atomname[newi] = gmx_strdup(ab[i][j].nname);
                             if (ab[i][j].oname != NULL && ab[i][j].atom) /* replace */
                             {                                            /*          newpdba->atom[newi].m    = ab[i][j].atom->m; */
 /*        newpdba->atom[newi].q    = ab[i][j].atom->q; */
index 87361b352691d4bba8670a9163389232863ee200..92133a60eff548449427545812f6df1282d76da0 100644 (file)
@@ -167,7 +167,7 @@ static void add_include(const char *include)
     {
         nincl++;
         srenew(incl, nincl);
-        incl[nincl-1] = strdup(include);
+        incl[nincl-1] = gmx_strdup(include);
     }
 }
 
@@ -199,7 +199,7 @@ static void add_define(const char *name, const char *value)
         ndef++;
         srenew(defs, ndef);
         i            = ndef - 1;
-        defs[i].name = strdup(name);
+        defs[i].name = gmx_strdup(name);
     }
     else if (defs[i].def)
     {
@@ -211,7 +211,7 @@ static void add_define(const char *name, const char *value)
     }
     if (value && strlen(value) > 0)
     {
-        defs[i].def  = strdup(value);
+        defs[i].def  = gmx_strdup(value);
     }
     else
     {
@@ -282,7 +282,7 @@ int cpp_open_file(const char *filenm, gmx_cpp_t *handle, char **cppopts)
     /* Find the file. First check whether it is in the current directory. */
     if (gmx_fexist(filenm))
     {
-        cpp->fn = strdup(filenm);
+        cpp->fn = gmx_strdup(filenm);
     }
     else
     {
@@ -332,7 +332,7 @@ int cpp_open_file(const char *filenm, gmx_cpp_t *handle, char **cppopts)
     {
         cpp->path = cpp->fn;
         *ptr      = '\0';
-        cpp->fn   = strdup(ptr+1);
+        cpp->fn   = gmx_strdup(ptr+1);
         snew(cpp->cwd, STRLEN);
 
         gmx_getcwd(cpp->cwd, STRLEN);
@@ -807,5 +807,5 @@ char *cpp_error(gmx_cpp_t *handlep, int status)
             (handle) ? handle->line_nr : -1,
             handle->line ? handle->line : "");
 
-    return strdup(buf);
+    return gmx_strdup(buf);
 }
index 8c54c5679c60a0efdc5dedc5d56390c616981be1..6768e8d81afd8b8bfbb2c9f9f56a50ae1ec696dc 100644 (file)
@@ -108,14 +108,14 @@ void read_ab(char *line, const char *fn, t_hack *hack)
     }
     for (i = 0; (i < hack->nctl); i++)
     {
-        hack->a[i] = strdup(a[i]);
+        hack->a[i] = gmx_strdup(a[i]);
     }
     for (; i < 4; i++)
     {
         hack->a[i] = NULL;
     }
     hack->oname = NULL;
-    hack->nname = strdup(hn);
+    hack->nname = gmx_strdup(hn);
     hack->atom  = NULL;
     hack->cgnr  = NOTSET;
     hack->bXSet = FALSE;
@@ -161,8 +161,8 @@ static void read_h_db_file(const char *hfn, int *nahptr, t_hackblock **ah)
         }
         srenew(aah, nah+1);
         clear_t_hackblock(&aah[nah]);
-        aah[nah].name     = strdup(buf);
-        aah[nah].filebase = strdup(filebase);
+        aah[nah].name     = gmx_strdup(buf);
+        aah[nah].filebase = gmx_strdup(filebase);
 
         if (sscanf(line+n, "%d", &nab) == 1)
         {
index dc7b66a6ad79c31d5d919d9f89e32f5ec97871f5..4afed71dd2f8acacb6c88853956c9267cebaf6d6 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <string.h>
 #include "hackblock.h"
+#include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/smalloc.h"
 #include "gromacs/math/vec.h"
 #include "names.h"
@@ -164,7 +165,7 @@ void clear_t_hack(t_hack *hack)
     }
 }
 
-#define safe_strdup(str) ((str != NULL) ? strdup(str) : NULL)
+#define safe_strdup(str) ((str != NULL) ? gmx_strdup(str) : NULL)
 
 static void copy_t_rbonded(t_rbonded *s, t_rbonded *d)
 {
index 6a71763a5a2c1683643bb8667882a930cfb3ad92..99c1ca92323081d8cbbe3bdc58d037531ba97123 100644 (file)
@@ -348,7 +348,7 @@ void set_histp(t_atoms *pdba, rvec *x, real angle, real dist)
                 }
 
                 snew(pdba->resinfo[hisind].rtp, 1);
-                *pdba->resinfo[hisind].rtp = strdup(hh[type]);
+                *pdba->resinfo[hisind].rtp = gmx_strdup(hh[type]);
             }
         }
     }
index e065e9e846a6da6476547acb07268540d3d5238f..5a4bec6381a65255d872f94b12b9eed967abef06 100644 (file)
@@ -105,7 +105,7 @@ static void rd_nm2type_file(const char *fn, int *nnm, t_nm2type **nmp)
                         {
                             gmx_fatal(FARGS, "Error on line %d of %s", line, libfilename);
                         }
-                        newbuf[i] = strdup(nbbuf);
+                        newbuf[i] = gmx_strdup(nbbuf);
                         strcat(format, "%*s%*s");
                     }
                 }
@@ -113,8 +113,8 @@ static void rd_nm2type_file(const char *fn, int *nnm, t_nm2type **nmp)
                 {
                     newbuf = NULL;
                 }
-                nm2t[nnnm].elem   = strdup(elem);
-                nm2t[nnnm].type   = strdup(type);
+                nm2t[nnnm].elem   = gmx_strdup(elem);
+                nm2t[nnnm].type   = gmx_strdup(type);
                 nm2t[nnnm].q      = qq;
                 nm2t[nnnm].m      = mm;
                 nm2t[nnnm].nbonds = nb;
index f165d723cc3e52cff9d5e3c86f851514d8f942b2..9e64f5c9943d7dc90180ac6ab420935dbe61616a 100644 (file)
@@ -1682,7 +1682,7 @@ int gmx_pdb2gmx(int argc, char *argv[])
             chains[i].pdba->atom[j] = pdba_all.atom[pdb_ch[si].start+j];
             snew(chains[i].pdba->atomname[j], 1);
             *chains[i].pdba->atomname[j] =
-                strdup(*pdba_all.atomname[pdb_ch[si].start+j]);
+                gmx_strdup(*pdba_all.atomname[pdb_ch[si].start+j]);
             chains[i].pdba->pdbinfo[j] = pdba_all.pdbinfo[pdb_ch[si].start+j];
             copy_rvec(pdbx[pdb_ch[si].start+j], chains[i].x[j]);
         }
@@ -1699,7 +1699,7 @@ int gmx_pdb2gmx(int argc, char *argv[])
         {
             chains[i].pdba->resinfo[j] = pdba_all.resinfo[k+j];
             snew(chains[i].pdba->resinfo[j].name, 1);
-            *chains[i].pdba->resinfo[j].name = strdup(*pdba_all.resinfo[k+j].name);
+            *chains[i].pdba->resinfo[j].name = gmx_strdup(*pdba_all.resinfo[k+j].name);
             /* make all chain identifiers equal to that of the chain */
             chains[i].pdba->resinfo[j].chainid = pdb_ch[si].chainid;
         }
@@ -2057,7 +2057,7 @@ int gmx_pdb2gmx(int argc, char *argv[])
 
             nincl++;
             srenew(incls, nincl);
-            incls[nincl-1] = strdup(itp_fn);
+            incls[nincl-1] = gmx_strdup(itp_fn);
             itp_file       = gmx_fio_fopen(itp_fn, "w");
         }
         else
@@ -2068,12 +2068,12 @@ int gmx_pdb2gmx(int argc, char *argv[])
         srenew(mols, nmol+1);
         if (cc->bAllWat)
         {
-            mols[nmol].name = strdup("SOL");
+            mols[nmol].name = gmx_strdup("SOL");
             mols[nmol].nr   = pdba->nres;
         }
         else
         {
-            mols[nmol].name = strdup(molname);
+            mols[nmol].name = gmx_strdup(molname);
             mols[nmol].nr   = 1;
         }
         nmol++;
index 8f4a126381f0c1aafa953fa23cdb7eb6e3fbb583..739dce9f152b41f7b5c08e4e89790e06ccfe691b 100644 (file)
@@ -172,7 +172,7 @@ choose_ff(const char *ffsel,
         ptr = strrchr(ffdirs[i], '/');
         if (ptr == NULL)
         {
-            ffs[i]     = strdup(ffdirs[i]);
+            ffs[i]     = gmx_strdup(ffdirs[i]);
             ffs_dir[i] = low_gmxlibfn(ffdirs[i], FALSE, FALSE);
             if (ffs_dir[i] == NULL)
             {
@@ -181,8 +181,8 @@ choose_ff(const char *ffsel,
         }
         else
         {
-            ffs[i]     = strdup(ptr+1);
-            ffs_dir[i] = strdup(ffdirs[i]);
+            ffs[i]     = gmx_strdup(ptr+1);
+            ffs_dir[i] = gmx_strdup(ffdirs[i]);
         }
         ffs_dir[i][strlen(ffs_dir[i])-strlen(ffs[i])-1] = '\0';
         /* Remove the extension from the ffdir name */
@@ -254,7 +254,7 @@ choose_ff(const char *ffsel,
             }
             else
             {
-                desc[i] = strdup(ffs[i]);
+                desc[i] = gmx_strdup(ffs[i]);
             }
         }
         /* Order force fields from the same dir alphabetically
@@ -371,7 +371,7 @@ void choose_watermodel(const char *wmsel, const char *ffdir,
     }
     else if (strcmp(wmsel, "select") != 0)
     {
-        *watermodel = strdup(wmsel);
+        *watermodel = gmx_strdup(wmsel);
 
         return;
     }
@@ -429,7 +429,7 @@ void choose_watermodel(const char *wmsel, const char *ffdir,
     }
     else
     {
-        *watermodel = strdup(model[sel]);
+        *watermodel = gmx_strdup(model[sel]);
     }
 
     for (i = 0; i < nwm; i++)
@@ -1000,7 +1000,7 @@ void add_atom_to_restp(t_restp *restp, int at_start, const t_hack *hack)
         }
         snew( restp->atomname[at_start+1+k], 1);
         restp->atom     [at_start+1+k] = *hack->atom;
-        *restp->atomname[at_start+1+k] = strdup(buf);
+        *restp->atomname[at_start+1+k] = gmx_strdup(buf);
         if (hack->cgnr != NOTSET)
         {
             restp->cgnr   [at_start+1+k] = hack->cgnr;
@@ -1174,7 +1174,7 @@ void get_hackblocks_rtp(t_hackblock **hb, t_restp **restp,
                             }
                             snew( (*restp)[i].atomname[l], 1);
                             (*restp)[i].atom[l]      =       *(*hb)[i].hack[j].atom;
-                            *(*restp)[i].atomname[l] = strdup((*hb)[i].hack[j].nname);
+                            *(*restp)[i].atomname[l] = gmx_strdup((*hb)[i].hack[j].nname);
                             if ( (*hb)[i].hack[j].cgnr != NOTSET)
                             {
                                 (*restp)[i].cgnr   [l] = (*hb)[i].hack[j].cgnr;
@@ -1331,7 +1331,7 @@ static gmx_bool match_atomnames_with_rtp_atom(t_atoms *pdba, rvec *x, int atind,
             }
             /* Rename the atom in pdba */
             snew(pdba->atomname[atind], 1);
-            *pdba->atomname[atind] = strdup(newnm);
+            *pdba->atomname[atind] = gmx_strdup(newnm);
         }
         else if (hbr->hack[j].oname != NULL && hbr->hack[j].nname == NULL &&
                  gmx_strcasecmp(oldnm, hbr->hack[j].oname) == 0)
index 445d8a6772632b64585a5232641dd8a499977d62..f58a75b0019e60fd00d62ae2bc6e69bf9b4f011b 100644 (file)
@@ -1420,7 +1420,7 @@ int str_nelem(const char *str, int maxptr, char *ptr[])
     int   np = 0;
     char *copy0, *copy;
 
-    copy0 = strdup(str);
+    copy0 = gmx_strdup(str);
     copy  = copy0;
     ltrim(copy);
     while (*copy != '\0')
@@ -1675,7 +1675,7 @@ static void do_wall_params(t_inputrec *ir,
         }
         for (i = 0; i < ir->nwall; i++)
         {
-            opts->wall_atomtype[i] = strdup(names[i]);
+            opts->wall_atomtype[i] = gmx_strdup(names[i]);
         }
 
         if (ir->wall_type == ewt93 || ir->wall_type == ewt104)
@@ -2338,7 +2338,7 @@ void get_ir(const char *mdparin, const char *mdparout,
     {
         if (ir->efep != efepNO)
         {
-            opts->couple_moltype = strdup(is->couple_moltype);
+            opts->couple_moltype = gmx_strdup(is->couple_moltype);
             if (opts->couple_lam0 == opts->couple_lam1)
             {
                 warning(wi, "The lambda=0 and lambda=1 states for coupling are identical");
@@ -2930,7 +2930,7 @@ static void decode_cos(char *s, t_cosines *cosine)
     double  a, phi;
     int     i;
 
-    t = strdup(s);
+    t = gmx_strdup(s);
     trim(t);
 
     cosine->n   = 0;
index 14e556a8e2c0b99923d56521c79e6987451cdef9..51d9eec7fca95c6f92fe918c820ff5f2fb318b07 100644 (file)
@@ -193,7 +193,7 @@ gmx_bool read_bondeds(int bt, FILE *in, char *line, t_restp *rtp)
         {
             if (sscanf(line+n, "%s%n", str, &ni) == 1)
             {
-                rtp->rb[bt].b[rtp->rb[bt].nb].a[j] = strdup(str);
+                rtp->rb[bt].b[rtp->rb[bt].nb].a[j] = gmx_strdup(str);
             }
             else
             {
@@ -210,7 +210,7 @@ gmx_bool read_bondeds(int bt, FILE *in, char *line, t_restp *rtp)
             n++;
         }
         rtrim(line+n);
-        rtp->rb[bt].b[rtp->rb[bt].nb].s = strdup(line+n);
+        rtp->rb[bt].b[rtp->rb[bt].nb].s = gmx_strdup(line+n);
         rtp->rb[bt].nb++;
     }
     /* give back unused memory */
@@ -450,8 +450,8 @@ void read_resall(char *rrdb, int *nrtpptr, t_restp **rtp,
         {
             gmx_fatal(FARGS, "in .rtp file at line:\n%s\n", line);
         }
-        rrtp[nrtp].resname  = strdup(header);
-        rrtp[nrtp].filebase = strdup(filebase);
+        rrtp[nrtp].resname  = gmx_strdup(header);
+        rrtp[nrtp].filebase = gmx_strdup(filebase);
 
         get_a_line(in, line, STRLEN);
         bError       = FALSE;
index 5fe81a7d7160f81491b79fd06faba634e4847d53..08ab832498e25fc985c86441e5c63c4018dd56b4 100644 (file)
@@ -90,12 +90,12 @@ t_specbond *get_specbonds(int *nspecbond)
         }
         else
         {
-            sb[n].res1    = strdup(r1buf);
-            sb[n].res2    = strdup(r2buf);
-            sb[n].newres1 = strdup(nr1buf);
-            sb[n].newres2 = strdup(nr2buf);
-            sb[n].atom1   = strdup(a1buf);
-            sb[n].atom2   = strdup(a2buf);
+            sb[n].res1    = gmx_strdup(r1buf);
+            sb[n].res2    = gmx_strdup(r2buf);
+            sb[n].newres1 = gmx_strdup(nr1buf);
+            sb[n].newres2 = gmx_strdup(nr2buf);
+            sb[n].atom1   = gmx_strdup(a1buf);
+            sb[n].atom2   = gmx_strdup(a2buf);
             sb[n].nbond1  = nb1;
             sb[n].nbond2  = nb2;
             sb[n].length  = length;
@@ -217,7 +217,7 @@ static void rename_1res(t_atoms *pdba, int resind, char *newres, gmx_bool bVerbo
     }
     /* this used to free *resname, which messes up the symtab! */
     snew(pdba->resinfo[resind].rtp, 1);
-    *pdba->resinfo[resind].rtp = strdup(newres);
+    *pdba->resinfo[resind].rtp = gmx_strdup(newres);
 }
 
 int mk_specbonds(t_atoms *pdba, rvec x[], gmx_bool bInteractive,
@@ -346,8 +346,8 @@ int mk_specbonds(t_atoms *pdba, rvec x[], gmx_bool bInteractive,
                         /* Store the residue numbers in the bonds array */
                         bonds[nbonds].res1 = specp[i];
                         bonds[nbonds].res2 = specp[j];
-                        bonds[nbonds].a1   = strdup(*pdba->atomname[ai]);
-                        bonds[nbonds].a2   = strdup(*pdba->atomname[aj]);
+                        bonds[nbonds].a1   = gmx_strdup(*pdba->atomname[ai]);
+                        bonds[nbonds].a2   = gmx_strdup(*pdba->atomname[aj]);
                         /* rename residues */
                         if (bSwap)
                         {
index 5c35580e0828a1ac48191306d63d2c52380dc49f..d5ad310cdb5cb482bb95d773069850308d4b7b7d 100644 (file)
@@ -118,7 +118,7 @@ static void read_atom(char *line, gmx_bool bAdd,
     {
         if (nr == 4)
         {
-            *nname = strdup(buf[i++]);
+            *nname = gmx_strdup(buf[i++]);
         }
         else
         {
@@ -288,8 +288,8 @@ static void read_ter_db_file(char *fn,
                     srenew(tb, maxnb);
                 }
                 clear_t_hackblock(&tb[nb]);
-                tb[nb].name     = strdup(header);
-                tb[nb].filebase = strdup(filebase);
+                tb[nb].name     = gmx_strdup(header);
+                tb[nb].filebase = gmx_strdup(filebase);
             }
         }
         else
@@ -327,7 +327,7 @@ static void read_ter_db_file(char *fn,
                         gmx_fatal(FARGS, "Reading Termini Database '%s': "
                                   "expected atom name on line\n%s", fn, line);
                     }
-                    tb[nb].hack[nh].oname = strdup(buf);
+                    tb[nb].hack[nh].oname = gmx_strdup(buf);
                     /* we only replace or delete one atom at a time */
                     tb[nb].hack[nh].nr = 1;
                 }
@@ -351,7 +351,7 @@ static void read_ter_db_file(char *fn,
                     {
                         if (tb[nb].hack[nh].oname != NULL)
                         {
-                            tb[nb].hack[nh].nname = strdup(tb[nb].hack[nh].oname);
+                            tb[nb].hack[nh].nname = gmx_strdup(tb[nb].hack[nh].oname);
                         }
                         else
                         {
@@ -369,7 +369,7 @@ static void read_ter_db_file(char *fn,
                 {
                     if (sscanf(line+n, "%s%n", buf, &ni) == 1)
                     {
-                        tb[nb].rb[kwnr].b[tb[nb].rb[kwnr].nb].a[j] = strdup(buf);
+                        tb[nb].rb[kwnr].b[tb[nb].rb[kwnr].nb].a[j] = gmx_strdup(buf);
                     }
                     else
                     {
@@ -383,7 +383,7 @@ static void read_ter_db_file(char *fn,
                 }
                 strcpy(buf, "");
                 sscanf(line+n, "%s", buf);
-                tb[nb].rb[kwnr].b[tb[nb].rb[kwnr].nb].s = strdup(buf);
+                tb[nb].rb[kwnr].b[tb[nb].rb[kwnr].nb].s = gmx_strdup(buf);
                 tb[nb].rb[kwnr].nb++;
             }
             else
index 1cb0f55f5be54501edd499a57042adc4bc2e26a3..b6b4baf3f24fd240b4dd6aa046bd382c7d247c6e 100644 (file)
@@ -84,8 +84,8 @@ static t_2morse *read_dissociation_energies(int *n2morse)
                 srenew(t2m, maxn2m);
             }
             /* Copy the values */
-            t2m[n2m].ai     = strdup(ai);
-            t2m[n2m].aj     = strdup(aj);
+            t2m[n2m].ai     = gmx_strdup(ai);
+            t2m[n2m].aj     = gmx_strdup(aj);
             t2m[n2m].e_diss = e_diss;
             /* Increment counter */
             n2m++;
index 1fc240d6a50c5e12d7d6a09f32372e8bd370bc1a..db8073b1c1a07137c95a9c4818db497fefab9ec4 100644 (file)
@@ -337,7 +337,7 @@ static char ** cpp_opts(const char *define, const char *include,
                     else
                     {
                         srenew(cppopts, ++ncppopts);
-                        cppopts[ncppopts-1] = strdup(buf);
+                        cppopts[ncppopts-1] = gmx_strdup(buf);
                     }
                     sfree(buf);
                     ptr = rptr;
@@ -640,7 +640,7 @@ static char **read_topol(const char *infile, const char *outfile,
 
             set_warning_line(wi, cpp_cur_file(&handle), cpp_cur_linenr(&handle));
 
-            pline = strdup(line);
+            pline = gmx_strdup(line);
 
             /* Strip trailing '\' from pline, if it exists */
             sl = strlen(pline);
@@ -658,7 +658,7 @@ static char **read_topol(const char *infile, const char *outfile,
                 /* Since we depend on the '\' being present to continue to read, we copy line
                  * to a tmp string, strip the '\' from that string, and cat it to pline
                  */
-                tmp_line = strdup(line);
+                tmp_line = gmx_strdup(line);
 
                 sl = strlen(tmp_line);
                 if ((sl > 0) && (tmp_line[sl-1] == CONTINUE))
@@ -697,7 +697,7 @@ static char **read_topol(const char *infile, const char *outfile,
                      * without the brackets into dirstr, then
                      * skip spaces and tabs on either side of directive
                      */
-                    dirstr = strdup((pline+1));
+                    dirstr = gmx_strdup((pline+1));
                     if ((dummy2 = strchr (dirstr, CLOSEDIR)) != NULL)
                     {
                         (*dummy2) = 0;
index 085e4c84efc8b6ae890446b23aa4ab0c59da3543..d9e3a69d19d7cf90005430ad4bede1824be0fdaf 100644 (file)
@@ -538,7 +538,7 @@ int gmx_x2top(int argc, char *argv[])
     bOPLS = (strcmp(forcefield, "oplsaa") == 0);
 
 
-    mymol.name = strdup(molnm);
+    mymol.name = gmx_strdup(molnm);
     mymol.nr   = 1;
 
     /* Init parameter lists */
index 2e55f750fab2beea1962a8f940ab5b2109df2c9c..9b728a1b7362f64ba3aa0ca5975499c8a97a1f25 100644 (file)
@@ -90,12 +90,12 @@ static void get_xlatoms(const char *fn, FILE *fp,
         }
 
         srenew(xl, n+1);
-        xl[n].filebase = strdup(filebase);
+        xl[n].filebase = gmx_strdup(filebase);
 
         /* Use wildcards... */
         if (strcmp(rbuf, "*") != 0)
         {
-            xl[n].res = strdup(rbuf);
+            xl[n].res = gmx_strdup(rbuf);
         }
         else
         {
@@ -108,8 +108,8 @@ static void get_xlatoms(const char *fn, FILE *fp,
             *_ptr = ' ';
         }
 
-        xl[n].atom    = strdup(abuf);
-        xl[n].replace = strdup(repbuf);
+        xl[n].atom    = gmx_strdup(abuf);
+        xl[n].replace = gmx_strdup(repbuf);
         n++;
     }
 
@@ -237,7 +237,7 @@ void rename_atoms(const char *xlfile, const char *ffdir,
                     /* Don't free the old atomname,
                      * since it might be in the symtab.
                      */
-                    ptr0 = strdup(xlatom[i].replace);
+                    ptr0 = gmx_strdup(xlatom[i].replace);
                     if (bVerbose)
                     {
                         printf("Renaming atom '%s' in residue %d %s to '%s'\n",
index e7ec3c72d2557068cf6b5491a6602addb1f60d04..592c82493269440fdf809afa2a3827cd94bdc18e 100644 (file)
@@ -75,10 +75,10 @@ int get_ebin_space(t_ebin *eb, int nener, const char *enm[], const char *unit)
         eb->e_sim[i].e    = 0;
         eb->e_sim[i].eav  = 0;
         eb->e_sim[i].esum = 0;
-        eb->enm[i].name   = strdup(enm[i-index]);
+        eb->enm[i].name   = gmx_strdup(enm[i-index]);
         if (unit != NULL)
         {
-            eb->enm[i].unit = strdup(unit);
+            eb->enm[i].unit = gmx_strdup(unit);
         }
         else
         {
@@ -105,7 +105,7 @@ int get_ebin_space(t_ebin *eb, int nener, const char *enm[], const char *unit)
                     }
                 }
             }
-            eb->enm[i].unit = strdup(u);
+            eb->enm[i].unit = gmx_strdup(u);
         }
     }
 
@@ -274,7 +274,7 @@ int main(int argc, char *argv[])
     {
         e[i] = i;
         sprintf(buf, "e%d", i);
-        ce[i] = strdup(buf);
+        ce[i] = gmx_strdup(buf);
     }
     ie = get_ebin_space(eb, NE, ce);
     add_ebin(eb, ie, NE, e, 0);
@@ -282,7 +282,7 @@ int main(int argc, char *argv[])
     {
         s[i] = i;
         sprintf(buf, "s%d", i);
-        cs[i] = strdup(buf);
+        cs[i] = gmx_strdup(buf);
     }
     is = get_ebin_space(eb, NS, cs);
     add_ebin(eb, is, NS, s, 0);
@@ -290,7 +290,7 @@ int main(int argc, char *argv[])
     {
         t[i] = i;
         sprintf(buf, "t%d", i);
-        ct[i] = strdup(buf);
+        ct[i] = gmx_strdup(buf);
     }
     it = get_ebin_space(eb, NT, ct);
     add_ebin(eb, it, NT, t, 0);
index e7811e9374f030192e2a84462fb70ffd23246899..ce60f69c127c0404a4a96d95427e3b4d3ea87f36 100644 (file)
@@ -547,7 +547,7 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
     {
         ni = groups->grps[egcTC].nm_ind[i];
         sprintf(buf, "T-%s", *(groups->grpname[ni]));
-        grpnms[i] = strdup(buf);
+        grpnms[i] = gmx_strdup(buf);
     }
     md->itemp = get_ebin_space(md->ebin, md->nTC, (const char **)grpnms,
                                unit_temp_K);
@@ -565,9 +565,9 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
                     for (j = 0; (j < md->nNHC); j++)
                     {
                         sprintf(buf, "Xi-%d-%s", j, bufi);
-                        grpnms[2*(i*md->nNHC+j)] = strdup(buf);
+                        grpnms[2*(i*md->nNHC+j)] = gmx_strdup(buf);
                         sprintf(buf, "vXi-%d-%s", j, bufi);
-                        grpnms[2*(i*md->nNHC+j)+1] = strdup(buf);
+                        grpnms[2*(i*md->nNHC+j)+1] = gmx_strdup(buf);
                     }
                 }
                 md->itc = get_ebin_space(md->ebin, md->mde_n,
@@ -580,9 +580,9 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
                         for (j = 0; (j < md->nNHC); j++)
                         {
                             sprintf(buf, "Xi-%d-%s", j, bufi);
-                            grpnms[2*(i*md->nNHC+j)] = strdup(buf);
+                            grpnms[2*(i*md->nNHC+j)] = gmx_strdup(buf);
                             sprintf(buf, "vXi-%d-%s", j, bufi);
-                            grpnms[2*(i*md->nNHC+j)+1] = strdup(buf);
+                            grpnms[2*(i*md->nNHC+j)+1] = gmx_strdup(buf);
                         }
                     }
                     md->itcb = get_ebin_space(md->ebin, md->mdeb_n,
@@ -596,9 +596,9 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
                     ni   = groups->grps[egcTC].nm_ind[i];
                     bufi = *(groups->grpname[ni]);
                     sprintf(buf, "Xi-%s", bufi);
-                    grpnms[2*i] = strdup(buf);
+                    grpnms[2*i] = gmx_strdup(buf);
                     sprintf(buf, "vXi-%s", bufi);
-                    grpnms[2*i+1] = strdup(buf);
+                    grpnms[2*i+1] = gmx_strdup(buf);
                 }
                 md->itc = get_ebin_space(md->ebin, md->mde_n,
                                          (const char **)grpnms, unit_invtime);
@@ -612,7 +612,7 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
         {
             ni = groups->grps[egcTC].nm_ind[i];
             sprintf(buf, "Lamb-%s", *(groups->grpname[ni]));
-            grpnms[i] = strdup(buf);
+            grpnms[i] = gmx_strdup(buf);
         }
         md->itc = get_ebin_space(md->ebin, md->mde_n, (const char **)grpnms, "");
     }
@@ -628,11 +628,11 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
         {
             ni = groups->grps[egcACC].nm_ind[i];
             sprintf(buf, "Ux-%s", *(groups->grpname[ni]));
-            grpnms[3*i+XX] = strdup(buf);
+            grpnms[3*i+XX] = gmx_strdup(buf);
             sprintf(buf, "Uy-%s", *(groups->grpname[ni]));
-            grpnms[3*i+YY] = strdup(buf);
+            grpnms[3*i+YY] = gmx_strdup(buf);
             sprintf(buf, "Uz-%s", *(groups->grpname[ni]));
-            grpnms[3*i+ZZ] = strdup(buf);
+            grpnms[3*i+ZZ] = gmx_strdup(buf);
         }
         md->iu = get_ebin_space(md->ebin, 3*md->nU, (const char **)grpnms, unit_vel);
         sfree(grpnms);
@@ -846,7 +846,7 @@ extern FILE *open_dhdl(const char *filename, const t_inputrec *ir,
     {
         /* state for the fep_vals, if we have alchemical sampling */
         sprintf(buf, "%s", "Thermodynamic state");
-        setname[s] = strdup(buf);
+        setname[s] = gmx_strdup(buf);
         s         += 1;
     }
 
@@ -862,7 +862,7 @@ extern FILE *open_dhdl(const char *filename, const t_inputrec *ir,
             default:
                 sprintf(buf, "%s (%s)", "Total Energy", unit_energy);
         }
-        setname[s] = strdup(buf);
+        setname[s] = gmx_strdup(buf);
         s         += 1;
     }
 
@@ -888,7 +888,7 @@ extern FILE *open_dhdl(const char *filename, const t_inputrec *ir,
                     sprintf(buf, "%s %s = %.4f", dhdl, efpt_singular_names[i],
                             lam);
                 }
-                setname[s] = strdup(buf);
+                setname[s] = gmx_strdup(buf);
                 s         += 1;
             }
         }
@@ -935,14 +935,14 @@ extern FILE *open_dhdl(const char *filename, const t_inputrec *ir,
                         ir->simtempvals->temperatures[s-(nsetsbegin)],
                         unit_temp_K);
             }
-            setname[s] = strdup(buf);
+            setname[s] = gmx_strdup(buf);
             s++;
         }
         if (write_pV)
         {
             np                     = sprintf(buf, "pV (%s)", unit_energy);
-            setname[nsetsextend-1] = strdup(buf);  /* the first entry after
-                                                      nsets */
+            setname[nsetsextend-1] = gmx_strdup(buf);  /* the first entry after
+                                                          nsets */
         }
 
         xvgr_legend(fp, nsetsextend, (const char **)setname, oenv);
@@ -1547,7 +1547,7 @@ void print_ebin(ener_file_t fp_ene, gmx_bool bEne, gmx_bool bDR, gmx_bool bOR,
                             nj = groups->grps[egcENER].nm_ind[j];
                             sprintf(buf, "%s-%s", *(groups->grpname[ni]),
                                     *(groups->grpname[nj]));
-                            md->print_grpnms[n++] = strdup(buf);
+                            md->print_grpnms[n++] = gmx_strdup(buf);
                         }
                     }
                 }
index 83d9c7c7adab89a0974953e83061b1ea3405c5be..07aaacca79e3a2fe59ea347bfebb5ee2f3671811 100644 (file)
@@ -200,7 +200,7 @@ void init_gaussian(t_commrec *cr, t_QMrec *qm, t_MMrec *mm)
 
         if (buf)
         {
-            qm->gauss_dir = strdup(buf);
+            qm->gauss_dir = gmx_strdup(buf);
         }
         else
         {
@@ -210,7 +210,7 @@ void init_gaussian(t_commrec *cr, t_QMrec *qm, t_MMrec *mm)
         buf = getenv("GMX_QM_GAUSS_EXE");
         if (buf)
         {
-            qm->gauss_exe = strdup(buf);
+            qm->gauss_exe = gmx_strdup(buf);
         }
         else
         {
@@ -219,7 +219,7 @@ void init_gaussian(t_commrec *cr, t_QMrec *qm, t_MMrec *mm)
         buf = getenv("GMX_QM_MODIFIED_LINKS_DIR");
         if (buf)
         {
-            qm->devel_dir = strdup (buf);
+            qm->devel_dir = gmx_strdup (buf);
         }
         else
         {
index 9452fb3c3eaa7f2fb510f5846b535637aed1ecaf..c19a5ef38c8ac71d13ab95d0af22291d0a2dc00a 100644 (file)
@@ -375,25 +375,25 @@ double do_tpi(FILE *fplog, t_commrec *cr,
         snew(leg, 4+nener);
         e = 0;
         sprintf(str, "-kT log(<Ve\\S-\\betaU\\N>/<V>)");
-        leg[e++] = strdup(str);
+        leg[e++] = gmx_strdup(str);
         sprintf(str, "f. -kT log<e\\S-\\betaU\\N>");
-        leg[e++] = strdup(str);
+        leg[e++] = gmx_strdup(str);
         sprintf(str, "f. <e\\S-\\betaU\\N>");
-        leg[e++] = strdup(str);
+        leg[e++] = gmx_strdup(str);
         sprintf(str, "f. V");
-        leg[e++] = strdup(str);
+        leg[e++] = gmx_strdup(str);
         sprintf(str, "f. <Ue\\S-\\betaU\\N>");
-        leg[e++] = strdup(str);
+        leg[e++] = gmx_strdup(str);
         for (i = 0; i < ngid; i++)
         {
             sprintf(str, "f. <U\\sVdW %s\\Ne\\S-\\betaU\\N>",
                     *(groups->grpname[groups->grps[egcENER].nm_ind[i]]));
-            leg[e++] = strdup(str);
+            leg[e++] = gmx_strdup(str);
         }
         if (bDispCorr)
         {
             sprintf(str, "f. <U\\sdisp c\\Ne\\S-\\betaU\\N>");
-            leg[e++] = strdup(str);
+            leg[e++] = gmx_strdup(str);
         }
         if (bCharge)
         {
@@ -401,17 +401,17 @@ double do_tpi(FILE *fplog, t_commrec *cr,
             {
                 sprintf(str, "f. <U\\sCoul %s\\Ne\\S-\\betaU\\N>",
                         *(groups->grpname[groups->grps[egcENER].nm_ind[i]]));
-                leg[e++] = strdup(str);
+                leg[e++] = gmx_strdup(str);
             }
             if (bRFExcl)
             {
                 sprintf(str, "f. <U\\sRF excl\\Ne\\S-\\betaU\\N>");
-                leg[e++] = strdup(str);
+                leg[e++] = gmx_strdup(str);
             }
             if (EEL_FULL(fr->eeltype))
             {
                 sprintf(str, "f. <U\\sCoul recip\\Ne\\S-\\betaU\\N>");
-                leg[e++] = strdup(str);
+                leg[e++] = gmx_strdup(str);
             }
         }
         xvgr_legend(fp_tpi, 4+nener, (const char**)leg, oenv);
index 677c48fa5d5864991ee7f0eb284c968c76667f36..d84d9b1539b2c1ba65cb1527607c247f0852a630 100644 (file)
@@ -177,7 +177,7 @@ static FILE *open_pull_out(const char *fn, t_pull *pull, const output_env_t oenv
                         if (pull->dim[m])
                         {
                             sprintf(buf, "%d %s%c", c+1, "c", 'X'+m);
-                            setname[nsets] = strdup(buf);
+                            setname[nsets] = gmx_strdup(buf);
                             nsets++;
                         }
                     }
@@ -187,7 +187,7 @@ static FILE *open_pull_out(const char *fn, t_pull *pull, const output_env_t oenv
                     if (pull->dim[m])
                     {
                         sprintf(buf, "%d %s%c", c+1, "d", 'X'+m);
-                        setname[nsets] = strdup(buf);
+                        setname[nsets] = gmx_strdup(buf);
                         nsets++;
                     }
                 }
@@ -195,7 +195,7 @@ static FILE *open_pull_out(const char *fn, t_pull *pull, const output_env_t oenv
             else
             {
                 sprintf(buf, "%d", c+1);
-                setname[nsets] = strdup(buf);
+                setname[nsets] = gmx_strdup(buf);
                 nsets++;
             }
         }
index 11367c6878373fd0e4f30e38188e2209ee697914..ef7a870ed630dc44e876e61e540d59541fbbf94a 100644 (file)
@@ -941,7 +941,7 @@ static FILE *open_rot_out(const char *fn, t_rot *rot, const output_env_t oenv)
             add_to_string_aligned(&LegendStr, buf);
 
             sprintf(buf2, "%s (degrees)", buf);
-            setname[nsets] = strdup(buf2);
+            setname[nsets] = gmx_strdup(buf2);
             nsets++;
         }
         for (g = 0; g < rot->ngrp; g++)
@@ -961,19 +961,19 @@ static FILE *open_rot_out(const char *fn, t_rot *rot, const output_env_t oenv)
             }
             add_to_string_aligned(&LegendStr, buf);
             sprintf(buf2, "%s (degrees)", buf);
-            setname[nsets] = strdup(buf2);
+            setname[nsets] = gmx_strdup(buf2);
             nsets++;
 
             sprintf(buf, "tau%d", g);
             add_to_string_aligned(&LegendStr, buf);
             sprintf(buf2, "%s (kJ/mol)", buf);
-            setname[nsets] = strdup(buf2);
+            setname[nsets] = gmx_strdup(buf2);
             nsets++;
 
             sprintf(buf, "energy%d", g);
             add_to_string_aligned(&LegendStr, buf);
             sprintf(buf2, "%s (kJ/mol)", buf);
-            setname[nsets] = strdup(buf2);
+            setname[nsets] = gmx_strdup(buf2);
             nsets++;
         }
         fprintf(fp, "#\n");
index 4ea326b91e493b515aa9e0e57c25fb91145ace6b..73b190d121044581bda0b985e7bfe0e6ed9b884f 100644 (file)
@@ -46,6 +46,7 @@
 #include "gromacs/selection/position.h"
 #include "gromacs/selection/selmethod.h"
 #include "gromacs/selection/selparam.h"
+#include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/messagestringcollector.h"
@@ -539,7 +540,7 @@ parse_values_varnum(const SelectionParserValueList    &values,
                 param->val.u.r[i++] = value->u.r.r1;
                 break;
             case STR_VALUE:
-                param->val.u.s[i++] = strdup(value->stringValue().c_str());
+                param->val.u.s[i++] = gmx_strdup(value->stringValue().c_str());
                 break;
             case POS_VALUE:  copy_rvec(value->u.x, param->val.u.p->x[i++]); break;
             default: /* Should not be reached */
@@ -864,7 +865,7 @@ parse_values_std(const SelectionParserValueList &values,
                     param->val.u.r[i] = value->u.r.r1;
                     break;
                 case STR_VALUE:
-                    param->val.u.s[i] = strdup(value->stringValue().c_str());
+                    param->val.u.s[i] = gmx_strdup(value->stringValue().c_str());
                     break;
                 case POS_VALUE:
                     gmx_ana_pos_init_const(&param->val.u.p[i], value->u.x);
index 3ba3e572a9b0708afeca7eb67fdc7feb1b52acb0..926aae201d4c1df0c3396181e2a6df3296692c81 100644 (file)
 #include "gromacs/selection/poscalc.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selmethod.h"
+#include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/file.h"
 #include "gromacs/utility/messagestringcollector.h"
@@ -579,7 +580,7 @@ _gmx_sel_init_arithmetic(const gmx::SelectionTreeElementPointer &left,
     buf[0] = op;
     buf[1] = 0;
     sel->setName(buf);
-    sel->u.arith.opstr = strdup(buf);
+    sel->u.arith.opstr = gmx_strdup(buf);
     sel->child         = left;
     sel->child->next   = right;
     return sel;
@@ -910,7 +911,7 @@ _gmx_sel_init_group_by_name(const char *name, yyscan_t scanner)
     SelectionTreeElementPointer sel(new SelectionTreeElement(SEL_GROUPREF));
     _gmx_selelem_set_vtype(sel, GROUP_VALUE);
     sel->setName(gmx::formatString("group \"%s\"", name));
-    sel->u.gref.name = strdup(name);
+    sel->u.gref.name = gmx_strdup(name);
     sel->u.gref.id   = -1;
 
     if (_gmx_sel_lexer_has_groups_set(scanner))
@@ -1077,7 +1078,7 @@ _gmx_sel_assign_variable(const char                             *name,
         sc->symtab->addVariable(name, root->child);
     }
     srenew(sc->varstrs, sc->nvars + 1);
-    sc->varstrs[sc->nvars] = strdup(pselstr);
+    sc->varstrs[sc->nvars] = gmx_strdup(pselstr);
     ++sc->nvars;
     if (_gmx_sel_is_lexer_interactive(scanner))
     {
index 9fdebc7118f85cd49b27d4e1e349d8f4e7652079..1b5ecb403719dea1e56ccd9f0aa73de30f448e74 100644 (file)
@@ -102,7 +102,7 @@ init_param_token(YYSTYPE *yylval, gmx_ana_selparam_t *param, bool bBoolNo)
     }
     else
     {
-        yylval->str = param->name ? strdup(param->name) : NULL;
+        yylval->str = param->name ? gmx_strdup(param->name) : NULL;
     }
     return PARAM;
 }
@@ -336,7 +336,7 @@ _gmx_sel_lexer_process_identifier(YYSTYPE *yylval, char *yytext, size_t yyleng,
     if (symtype == gmx::SelectionParserSymbol::PositionSymbol)
     {
         state->bMatchOf    = true;
-        yylval->str        = strdup(symbol->name().c_str());
+        yylval->str        = gmx_strdup(symbol->name().c_str());
         state->prev_pos_kw = 2;
         return KEYWORD_POS;
     }
index 9a2f39e028a05cdaa10af69858fb4eb35fd5e683..ec090acc220131cb27bacaed6cb23a58f64f3165 100644 (file)
@@ -173,7 +173,7 @@ void TopologyManager::initAtomTypes(int count, const char *const types[])
     atomtypes_.reserve(count);
     for (int i = 0; i < count; ++i)
     {
-        atomtypes_.push_back(strdup(types[i]));
+        atomtypes_.push_back(gmx_strdup(types[i]));
     }
     snew(top_->atoms.atomtype, top_->atoms.nr);
     for (int i = 0, j = 0; i < top_->atoms.nr; ++i, ++j)
index 8d593b37eef195a93cdecbe34e6f57cfcfc534a5..926826b5ff6fd9ec3ebe38d5bbf7c4e38ec8cc78 100644 (file)
@@ -180,8 +180,8 @@ static void add_prop(aprop_t *ap, gmx_residuetype_t *restype,
                 ap->bAvail[i] = FALSE;
             }
         }
-        ap->atomnm[ap->nprop] = strdup(atomnm);
-        ap->resnm[ap->nprop]  = strdup(resnm);
+        ap->atomnm[ap->nprop] = gmx_strdup(atomnm);
+        ap->resnm[ap->nprop]  = gmx_strdup(resnm);
         j                     = ap->nprop;
         ap->nprop++;
     }
@@ -252,7 +252,7 @@ static void set_prop(gmx_atomprop_t aps, int eprop)
     ap = &ap2->prop[eprop];
     if (!ap->bSet)
     {
-        ap->db  = strdup(fns[eprop]);
+        ap->db  = gmx_strdup(fns[eprop]);
         ap->def = def[eprop];
         read_prop(aps, eprop, fac[eprop]);
 
index 34201277c9ffa5c30c91aeed4faaad1fe1c399b5..65f9b2abae3f97adfc764b83f1873548a2113e9c 100644 (file)
@@ -127,7 +127,7 @@ void add_grp(t_blocka *b, char ***gnames, int nra, atom_id a[], const char *name
 
     srenew(b->index, b->nr+2);
     srenew(*gnames, b->nr+1);
-    (*gnames)[b->nr] = strdup(name);
+    (*gnames)[b->nr] = gmx_strdup(name);
 
     srenew(b->a, b->nra+nra);
     for (i = 0; (i < nra); i++)
@@ -275,9 +275,9 @@ static void analyse_other(const char ** restype, t_atoms *atoms,
                 if (l == nrestp)
                 {
                     srenew(restp, nrestp+1);
-                    restp[nrestp].rname = strdup(rname);
+                    restp[nrestp].rname = gmx_strdup(rname);
                     restp[nrestp].bNeg  = FALSE;
-                    restp[nrestp].gname = strdup(rname);
+                    restp[nrestp].gname = gmx_strdup(rname);
                     nrestp++;
 
                 }
@@ -624,7 +624,7 @@ void analyse(t_atoms *atoms, t_blocka *gb, char ***gn, gmx_bool bASK, gmx_bool b
         if (!found)
         {
             srenew(p_typename, ntypes+1);
-            p_typename[ntypes++] = strdup(restype[i]);
+            p_typename[ntypes++] = gmx_strdup(restype[i]);
         }
     }
 
@@ -706,7 +706,7 @@ void analyse(t_atoms *atoms, t_blocka *gb, char ***gn, gmx_bool bASK, gmx_bool b
     {
         srenew(gb->index, gb->nr+2);
         srenew(*gn, gb->nr+1);
-        (*gn)[gb->nr] = strdup("Water_and_ions");
+        (*gn)[gb->nr] = gmx_strdup("Water_and_ions");
         srenew(gb->a, gb->nra+nwater+nion);
         if (nwater > 0)
         {
@@ -776,7 +776,7 @@ t_blocka *init_index(const char *gfile, char ***grpname)
                 b->index[0] = 0;
             }
             b->index[b->nr]     = b->index[b->nr-1];
-            (*grpname)[b->nr-1] = strdup(str);
+            (*grpname)[b->nr-1] = gmx_strdup(str);
         }
         else
         {
@@ -968,7 +968,7 @@ static void rd_groups(t_blocka *grps, char **grpname, char *gnames[],
             fprintf(stderr, "There is one group in the index\n");
             gnr1 = 0;
         }
-        gnames[i] = strdup(grpname[gnr1]);
+        gnames[i] = gmx_strdup(grpname[gnr1]);
         isize[i]  = grps->index[gnr1+1]-grps->index[gnr1];
         snew(index[i], isize[i]);
         for (j = 0; (j < isize[i]); j++)
index 763d6f4f4241567bac51d37779eb86b429c475e4..98a99e3a9a82147b4dbf0ac1c3019e4ae996e6e5 100644 (file)
@@ -166,7 +166,7 @@ static char **enter_buf(t_symtab *symtab, char *name)
             if (symbuf->buf[i] == NULL)
             {
                 symtab->nr++;
-                symbuf->buf[i] = strdup(name);
+                symbuf->buf[i] = gmx_strdup(name);
                 return &(symbuf->buf[i]);
             }
             else if (strcmp(symbuf->buf[i], name) == 0)
@@ -190,7 +190,7 @@ static char **enter_buf(t_symtab *symtab, char *name)
     symbuf       = symbuf->next;
 
     symtab->nr++;
-    symbuf->buf[0] = strdup(name);
+    symbuf->buf[0] = gmx_strdup(name);
     return &(symbuf->buf[0]);
 }
 
index 21012794ec4404399a4059dfe75efe78fbf4da87..a8a39f11e050e63b2e7fe5ba757bb9d725f00bd3 100644 (file)
@@ -42,6 +42,7 @@
 #include <algorithm>
 
 #include "macros.h"
+#include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/smalloc.h"
 
 #include "x11.h"
@@ -116,7 +117,7 @@ static bool VBCallBack(t_x11 *x11, XEvent *event, Window /*w*/, void *data)
 void set_vbtime(t_x11 *x11, t_butbox *vbox, char *text)
 {
     sfree(vbox->wd.text);
-    vbox->wd.text = strdup(text);
+    vbox->wd.text = gmx_strdup(text);
     ExposeWin(x11->disp, vbox->wd.self);
 }
 
index 19a7868da932e51536328560c4ba9ac9d67de6d5..a4a2f5a7f08156fc8ede085f5c07ac525a2c3ae3 100644 (file)
@@ -203,7 +203,7 @@ static t_fsimple *NewFSimple(void)
 static void AddFItemName(t_fitem *fitem, char *name)
 {
     srenew(fitem->name, ++fitem->nname);
-    fitem->name[fitem->nname-1] = strdup(name);
+    fitem->name[fitem->nname-1] = gmx_strdup(name);
 }
 
 static t_fgroup *NewFGroup(void)
@@ -358,10 +358,10 @@ static t_fitem *ScanFItem(const char *infile, FILE *in, char *buf)
     ReadQuoteString(infile, in, get);
     ReadQuoteString(infile, in, def);
     ReadQuoteString(infile, in, help);
-    fitem->set  = strdup(set);
-    fitem->get  = strdup(get);
-    fitem->def  = strdup(def);
-    fitem->help = strdup(help);
+    fitem->set  = gmx_strdup(set);
+    fitem->get  = gmx_strdup(get);
+    fitem->def  = gmx_strdup(def);
+    fitem->help = gmx_strdup(help);
 
     return fitem;
 }
@@ -398,7 +398,7 @@ t_fgrid *FGridFromFile(const char *infile)
         {
             fgroup = AddFGridFGroup(fgrid);
             ReadQuoteString(infile, in, buf);
-            fgroup->name = strdup(buf);
+            fgroup->name = gmx_strdup(buf);
             if ((fscanf(in, "%5d%5d%5d%5d", &fgroup->x, &fgroup->y, &fgroup->w, &fgroup->h)) != 4)
             {
                 ReadDlgErr(infile, eNOVALS, "group x,y,w,h");
index 30f7a31a2ff32b575bea8504101e412e30e92d0b..391dadaf9102a3d2043e51e855bc67a182d5c57c 100644 (file)
@@ -230,7 +230,7 @@ void set_file(t_x11 *x11, t_manager *man, const char *trajectory,
     man->natom =
         read_first_x(man->oenv, &man->status, trajectory, &(man->time), &(man->x),
                      man->box);
-    man->trajfile = strdup(trajectory);
+    man->trajfile = gmx_strdup(trajectory);
     if (man->natom > man->top.atoms.nr)
     {
         gmx_fatal(FARGS, "Topology %s (%d atoms) and trajectory %s (%d atoms) "
@@ -240,7 +240,7 @@ void set_file(t_x11 *x11, t_manager *man, const char *trajectory,
 
     cool_quote(quote, 255, NULL);
     sprintf(buf, "%s: %s", *man->top.name, quote);
-    man->title.text = strdup(buf);
+    man->title.text = gmx_strdup(buf);
     man->view       = init_view(man->box);
     at              = &(man->top.atoms);
     aps             = gmx_atomprop_init();
index 0dc1a8913c4f061ebde7f0c16ae83c66eef26340..905032624271720335aa2d8cee97dd72ce6302ec 100644 (file)
@@ -40,6 +40,7 @@
 #include <string.h>
 
 #include "typedefs.h"
+#include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/smalloc.h"
 #include "Xstuff.h"
 #include "x11.h"
@@ -318,7 +319,7 @@ t_x11 *GetX11(int *argc, char *argv[])
     bool            bVerbose = false;
     int             i;
 
-    title = strdup(argv[0]);
+    title = gmx_strdup(argv[0]);
 
     /* First check environment */
     fontname = getenv("GMX_FONT");
@@ -355,7 +356,7 @@ t_x11 *GetX11(int *argc, char *argv[])
                             break;
                         case 't':
                             sfree(title);
-                            title = strdup(argv[++i]);
+                            title = gmx_strdup(argv[++i]);
                             break;
                         case 'v':
                             bVerbose = true;
@@ -481,7 +482,7 @@ t_x11 *GetX11(int *argc, char *argv[])
     {
         x11->bg = LIGHTGREY;
     }
-    x11->title = strdup(title);
+    x11->title = gmx_strdup(title);
     sfree(title);
     x11->wlist              = NULL;
     x11->GetNamedColor      = &GetNamedColor;
index 0769d670567f544c2b56044c3f5f1d27b746c502..c7f21ad9c22d00f40413a45e9f34c1e86115dbba 100644 (file)
@@ -419,7 +419,7 @@ void HelpNow(t_dlg *dlg, t_dlgitem *dlgitem)
             if (bCont)
             {
                 srenew(lines, ++nlines);
-                lines[nlines-1] = strdup(buf);
+                lines[nlines-1] = gmx_strdup(buf);
             }
         }
     }
@@ -774,7 +774,7 @@ t_dlg *CreateDlg(t_x11 *x11, Window Parent, const char *title,
     dlg->data = data;
     if (title)
     {
-        dlg->title = strdup(title);
+        dlg->title = gmx_strdup(title);
     }
     else
     {
index 09940872a5124fd609137b61706b5328f8ff37fe..cf21f2c3dc13f5c5b8ffe6be08f825d2edf9f945 100644 (file)
@@ -420,7 +420,7 @@ static int WndProcET(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event)
         case ButtonPress:
             /* Calculate new position for caret */
             et->pos = strlen(et->buf);
-            bp      = strdup(et->buf);
+            bp      = gmx_strdup(et->buf);
             xp      = event->xbutton.x-XTextWidth(x11->font, win->text, strlen(win->text))-
                 XCARET;
             while ((et->pos > 0) && (XTextWidth(x11->font, bp, strlen(bp)) > xp))
@@ -571,7 +571,7 @@ t_dlgitem *CreateButton(t_x11 *x11,
     }
     else
     {
-        lab = strdup(szLab);
+        lab = gmx_strdup(szLab);
     }
     InitWin(&(dlgitem->win), x0, y0, w, h, bw, szLab);
     sfree(lab);
@@ -709,7 +709,7 @@ t_dlgitem *CreateStaticText(t_x11 *x11,
     snew(dlgitem->u.statictext.lines, nlines);
     for (i = 0; (i < nlines); i++)
     {
-        dlgitem->u.statictext.lines[i] = strdup(lines[i]);
+        dlgitem->u.statictext.lines[i] = gmx_strdup(lines[i]);
     }
     dlgitem->WndProc = WndProcST;
 
@@ -755,7 +755,7 @@ t_dlgitem *CreateEditText(t_x11 *x11,
     return dlgitem;
 }
 
-#define SC(src) (strlen(src) ? strdup(src) : NULL)
+#define SC(src) (strlen(src) ? gmx_strdup(src) : NULL)
 
 void SetDlgitemOpts(t_dlgitem *dlgitem, bool bUseMon,
                     char *set, char *get, char *help)
index 83ac88fc572d0bdbd7510d0cd802381dd52b930f..890d2f6acd1feee99983c8858484de55533b565e 100644 (file)
@@ -39,6 +39,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/smalloc.h"
 #include "typedefs.h"
 #include "xutil.h"
@@ -165,7 +166,7 @@ void InitWin(t_windata *win, int x0, int y0, int w, int h, int bw, const char *t
     win->cursor = 0;
     if (text)
     {
-        win->text = strdup(text);
+        win->text = gmx_strdup(text);
     }
     else
     {