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
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;
{
srenew(names, count);
sprintf(buf, "Vfl_%d", count);
- names[count-1] = strdup(buf);
+ names[count-1] = gmx_strdup(buf);
actual = actual->next_edi;
count++;
}
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)++;
}
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))
}
else
{
- nm->unit = strdup("kJ/mol");
+ nm->unit = gmx_strdup("kJ/mol");
}
}
}
*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);
}
}
}
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
{
if (tfn[i].fn)
{
- ret[i].fn = strdup(tfn[i].fn);
+ ret[i].fn = gmx_strdup(tfn[i].fn);
}
else
{
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]);
}
}
}
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 */
/* 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;
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;
line = strchr(line, '\"');
line++;
line2string(&line);
- map[m].desc = strdup(line);
+ map[m].desc = gmx_strdup(line);
m++;
}
}
#ifdef DEBUG
fprintf(stderr, "Have read: %s\n", buf);
#endif
- ptr[i] = strdup(buf);
+ ptr[i] = gmx_strdup(buf);
}
gmx_ffclose(in);
maxi += 50;
srenew(ptr, maxi);
}
- ptr[i] = strdup(buf);
+ ptr[i] = gmx_strdup(buf);
i++;
}
nstr = i;
for (i = 0; (i < nr); i++)
{
gmx_fio_do_string(fio, buf);
- symbuf->buf[i] = strdup(buf);
+ symbuf->buf[i] = gmx_strdup(buf);
}
}
else
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;
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),
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)
{
{
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++)
{
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++)
{
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.");
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",
for (i = 0; i < NLEG; i++)
{
- leg[i] = strdup(const_leg[i]);
+ leg[i] = gmx_strdup(const_leg[i]);
}
/* Print order parameters */
{
index[i] = i;
}
- gname = strdup("mols");
+ gname = gmx_strdup("mols");
}
else
{
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);
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 *)
int i;
- OOO = strdup("O");
+ OOO = gmx_strdup("O");
for (i = 0; (i < atoms->nr); i++)
{
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",
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)
{
}
if (bSum)
{
- leg[nset] = strdup("Sum");
+ leg[nset] = gmx_strdup("Sum");
xvgr_legend(out, nset+1, (const char**)leg, oenv);
}
else
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);
}
}
}
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] == '-')))
{
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);
}
}
/* 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++;
}
}
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);
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)
{
c = (*string)[0];
(*string)++;
- s = strdup((*string));
+ s = gmx_strdup((*string));
sp = strchr(s, c);
if (sp != NULL)
{
{
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++)
{
{
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++;
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];
{
sscanf(string, "%s", gname);
sfree((*gn)[sel_nr]);
- (*gn)[sel_nr] = strdup(gname);
+ (*gn)[sel_nr] = gmx_strdup(gname);
}
}
}
copy2block(nr, index, block);
srenew(*gn, block->nr);
newgroup = block->nr-1;
- (*gn)[newgroup] = strdup(gname);
+ (*gn)[newgroup] = gmx_strdup(gname);
}
else
{
{
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)
{
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);
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)
gmx_fatal(FARGS, "Unsupported function type '%s' selected",
interaction_function[ftype].longname);
}
- grpnames[ind] = strdup(buf);
+ grpnames[ind] = gmx_strdup(buf);
ind++;
}
}
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);
{
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;
}
if (bFound)
{
- *nname = strdup(equiv[i-1][0].nname);
+ *nname = gmx_strdup(equiv[i-1][0].nname);
}
return bFound;
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)
{
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)
{
*(atoms->resinfo[resnr].name),
atoms->resinfo[resnr].nr,
anr+1);
- cg[ncg].label = strdup(buf);
+ cg[ncg].label = gmx_strdup(buf);
ncg++;
}
}
{
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++)
{
{
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';
}
{
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);
}
}
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++)
}
else
{
- fn = strdup(fnhist);
+ fn = gmx_strdup(fnhist);
strcpy(title, "Umbrella histograms");
}
#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"
}
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)
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++)
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++)
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++;
}
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;
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);
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
{
{
/* 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);
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
{
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++;
if (ii == -1)
{
sprintf(buf, "%d", def);
- (*inp)[(*ninp)-1].value = strdup(buf);
+ (*inp)[(*ninp)-1].value = gmx_strdup(buf);
return def;
}
if (ii == -1)
{
sprintf(buf, "%"GMX_PRId64, def);
- (*inp)[(*ninp)-1].value = strdup(buf);
+ (*inp)[(*ninp)-1].value = gmx_strdup(buf);
return def;
}
if (ii == -1)
{
sprintf(buf, "%g", def);
- (*inp)[(*ninp)-1].value = strdup(buf);
+ (*inp)[(*ninp)-1].value = gmx_strdup(buf);
return def;
}
if (def)
{
sprintf(buf, "%s", def);
- (*inp)[(*ninp)-1].value = strdup(buf);
+ (*inp)[(*ninp)-1].value = gmx_strdup(buf);
}
else
{
if (ii == -1)
{
- (*inp)[(*ninp)-1].value = strdup(defs[0]);
+ (*inp)[(*ninp)-1].value = gmx_strdup(defs[0]);
return 0;
}
fprintf(stderr, "%s\n", buf);
}
- (*inp)[ii].value = strdup(defs[0]);
+ (*inp)[ii].value = gmx_strdup(defs[0]);
return 0;
}
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)
{
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++;
{
/* We have a match */
srenew(dns, n+1);
- dns[n] = strdup(f_short[i]);
+ dns[n] = gmx_strdup(f_short[i]);
n++;
}
}
#include "network.h"
#include "gromacs/topology/symtab.h"
+#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
{
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,
{
if (hb[rnr].name == NULL)
{
- hb[rnr].name = strdup(ahptr->name);
+ hb[rnr].name = gmx_strdup(ahptr->name);
}
merge_hacks(ahptr, &hb[rnr]);
}
{
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';
}
}
(*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)
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; */
{
nincl++;
srenew(incl, nincl);
- incl[nincl-1] = strdup(include);
+ incl[nincl-1] = gmx_strdup(include);
}
}
ndef++;
srenew(defs, ndef);
i = ndef - 1;
- defs[i].name = strdup(name);
+ defs[i].name = gmx_strdup(name);
}
else if (defs[i].def)
{
}
if (value && strlen(value) > 0)
{
- defs[i].def = strdup(value);
+ defs[i].def = gmx_strdup(value);
}
else
{
/* 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
{
{
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);
(handle) ? handle->line_nr : -1,
handle->line ? handle->line : "");
- return strdup(buf);
+ return gmx_strdup(buf);
}
}
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;
}
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)
{
#include <string.h>
#include "hackblock.h"
+#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/math/vec.h"
#include "names.h"
}
}
-#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)
{
}
snew(pdba->resinfo[hisind].rtp, 1);
- *pdba->resinfo[hisind].rtp = strdup(hh[type]);
+ *pdba->resinfo[hisind].rtp = gmx_strdup(hh[type]);
}
}
}
{
gmx_fatal(FARGS, "Error on line %d of %s", line, libfilename);
}
- newbuf[i] = strdup(nbbuf);
+ newbuf[i] = gmx_strdup(nbbuf);
strcat(format, "%*s%*s");
}
}
{
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;
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]);
}
{
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;
}
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
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++;
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)
{
}
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 */
}
else
{
- desc[i] = strdup(ffs[i]);
+ desc[i] = gmx_strdup(ffs[i]);
}
}
/* Order force fields from the same dir alphabetically
}
else if (strcmp(wmsel, "select") != 0)
{
- *watermodel = strdup(wmsel);
+ *watermodel = gmx_strdup(wmsel);
return;
}
}
else
{
- *watermodel = strdup(model[sel]);
+ *watermodel = gmx_strdup(model[sel]);
}
for (i = 0; i < nwm; i++)
}
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;
}
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;
}
/* 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)
int np = 0;
char *copy0, *copy;
- copy0 = strdup(str);
+ copy0 = gmx_strdup(str);
copy = copy0;
ltrim(copy);
while (*copy != '\0')
}
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)
{
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");
double a, phi;
int i;
- t = strdup(s);
+ t = gmx_strdup(s);
trim(t);
cosine->n = 0;
{
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
{
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 */
{
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;
}
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;
}
/* 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,
/* 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)
{
{
if (nr == 4)
{
- *nname = strdup(buf[i++]);
+ *nname = gmx_strdup(buf[i++]);
}
else
{
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
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;
}
{
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
{
{
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
{
}
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
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++;
else
{
srenew(cppopts, ++ncppopts);
- cppopts[ncppopts-1] = strdup(buf);
+ cppopts[ncppopts-1] = gmx_strdup(buf);
}
sfree(buf);
ptr = rptr;
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);
/* 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))
* 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;
bOPLS = (strcmp(forcefield, "oplsaa") == 0);
- mymol.name = strdup(molnm);
+ mymol.name = gmx_strdup(molnm);
mymol.nr = 1;
/* Init parameter lists */
}
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
{
*_ptr = ' ';
}
- xl[n].atom = strdup(abuf);
- xl[n].replace = strdup(repbuf);
+ xl[n].atom = gmx_strdup(abuf);
+ xl[n].replace = gmx_strdup(repbuf);
n++;
}
/* 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",
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
{
}
}
}
- eb->enm[i].unit = strdup(u);
+ eb->enm[i].unit = gmx_strdup(u);
}
}
{
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);
{
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);
{
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);
{
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);
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,
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,
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);
{
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, "");
}
{
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);
{
/* 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;
}
default:
sprintf(buf, "%s (%s)", "Total Energy", unit_energy);
}
- setname[s] = strdup(buf);
+ setname[s] = gmx_strdup(buf);
s += 1;
}
sprintf(buf, "%s %s = %.4f", dhdl, efpt_singular_names[i],
lam);
}
- setname[s] = strdup(buf);
+ setname[s] = gmx_strdup(buf);
s += 1;
}
}
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);
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);
}
}
}
if (buf)
{
- qm->gauss_dir = strdup(buf);
+ qm->gauss_dir = gmx_strdup(buf);
}
else
{
buf = getenv("GMX_QM_GAUSS_EXE");
if (buf)
{
- qm->gauss_exe = strdup(buf);
+ qm->gauss_exe = gmx_strdup(buf);
}
else
{
buf = getenv("GMX_QM_MODIFIED_LINKS_DIR");
if (buf)
{
- qm->devel_dir = strdup (buf);
+ qm->devel_dir = gmx_strdup (buf);
}
else
{
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)
{
{
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);
if (pull->dim[m])
{
sprintf(buf, "%d %s%c", c+1, "c", 'X'+m);
- setname[nsets] = strdup(buf);
+ setname[nsets] = gmx_strdup(buf);
nsets++;
}
}
if (pull->dim[m])
{
sprintf(buf, "%d %s%c", c+1, "d", 'X'+m);
- setname[nsets] = strdup(buf);
+ setname[nsets] = gmx_strdup(buf);
nsets++;
}
}
else
{
sprintf(buf, "%d", c+1);
- setname[nsets] = strdup(buf);
+ setname[nsets] = gmx_strdup(buf);
nsets++;
}
}
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++)
}
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");
#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"
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 */
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(¶m->val.u.p[i], value->u.x);
#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"
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;
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))
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))
{
}
else
{
- yylval->str = param->name ? strdup(param->name) : NULL;
+ yylval->str = param->name ? gmx_strdup(param->name) : NULL;
}
return PARAM;
}
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;
}
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)
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++;
}
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]);
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++)
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++;
}
if (!found)
{
srenew(p_typename, ntypes+1);
- p_typename[ntypes++] = strdup(restype[i]);
+ p_typename[ntypes++] = gmx_strdup(restype[i]);
}
}
{
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)
{
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
{
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++)
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)
symbuf = symbuf->next;
symtab->nr++;
- symbuf->buf[0] = strdup(name);
+ symbuf->buf[0] = gmx_strdup(name);
return &(symbuf->buf[0]);
}
#include <algorithm>
#include "macros.h"
+#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/smalloc.h"
#include "x11.h"
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);
}
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)
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;
}
{
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");
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) "
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();
#include <string.h>
#include "typedefs.h"
+#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/smalloc.h"
#include "Xstuff.h"
#include "x11.h"
bool bVerbose = false;
int i;
- title = strdup(argv[0]);
+ title = gmx_strdup(argv[0]);
/* First check environment */
fontname = getenv("GMX_FONT");
break;
case 't':
sfree(title);
- title = strdup(argv[++i]);
+ title = gmx_strdup(argv[++i]);
break;
case 'v':
bVerbose = true;
{
x11->bg = LIGHTGREY;
}
- x11->title = strdup(title);
+ x11->title = gmx_strdup(title);
sfree(title);
x11->wlist = NULL;
x11->GetNamedColor = &GetNamedColor;
if (bCont)
{
srenew(lines, ++nlines);
- lines[nlines-1] = strdup(buf);
+ lines[nlines-1] = gmx_strdup(buf);
}
}
}
dlg->data = data;
if (title)
{
- dlg->title = strdup(title);
+ dlg->title = gmx_strdup(title);
}
else
{
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))
}
else
{
- lab = strdup(szLab);
+ lab = gmx_strdup(szLab);
}
InitWin(&(dlgitem->win), x0, y0, w, h, bw, szLab);
sfree(lab);
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;
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)
#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"
win->cursor = 0;
if (text)
{
- win->text = strdup(text);
+ win->text = gmx_strdup(text);
}
else
{