static char *repallww(char *s,int nsr,t_sandr sa[]) { int i; char *buf,*buf2; buf=s; for(i=0; (i<nsr); i++) { buf2=replaceww(buf,sa[i].search,sa[i].replace); if (i && buf) sfree(buf); buf=buf2; } return buf; }
static char *repallww(const char *s,int nsr,const t_sandr sa[]) { int i; char *buf1,*buf2; /* Copy input to a non-constant char buffer. * buf1 is allocated here */ buf1=gmx_strdup(s); for(i=0; (i<nsr); i++) { /* Replace in buffer1, put result in buffer2. * buf2 is allocated here. */ buf2=replaceww(buf1,sa[i].search,sa[i].replace); sfree(buf1); buf1=buf2; } return buf1; }