Replaced strdups with gmx_strdups so that they can be sfree()'d safely.
authorSander Pronk <pronk@cbr.su.se>
Thu, 3 Mar 2011 17:17:24 +0000 (18:17 +0100)
committerSander Pronk <pronk@cbr.su.se>
Thu, 3 Mar 2011 17:17:24 +0000 (18:17 +0100)
Patch providided by Scott Field from Microsoft as part of NUMA optimizations.

src/gmxlib/checkpoint.c
src/gmxlib/futil.c
src/gmxlib/main.c
src/gmxlib/replace.c
src/gmxlib/wman.c

index 28b95eb1f2fbfd6322f5638b7abb38e43e72a805..c9a95ecd381aed1c62da3930d3a09b60e5d39aba 100644 (file)
@@ -1236,11 +1236,11 @@ void write_checkpoint(const char *fn,gmx_bool bNumberAndKeep,
     }
 
     
-    version = strdup(VERSION);
-    btime   = strdup(BUILD_TIME);
-    buser   = strdup(BUILD_USER);
-    bmach   = strdup(BUILD_MACHINE);
-    fprog   = strdup(Program());
+    version = gmx_strdup(VERSION);
+    btime   = gmx_strdup(BUILD_TIME);
+    buser   = gmx_strdup(BUILD_USER);
+    bmach   = gmx_strdup(BUILD_MACHINE);
+    fprog   = gmx_strdup(Program());
 
     ftime   = &(timebuf[0]);
     
index 1c58f6d73e17a80610bc5c2afa3fe370bd230eef..a653b083b0868a9387599a1a877362dafbc61b58 100644 (file)
@@ -370,13 +370,13 @@ static char *backup_fn(const char *file,int count_max)
      * a '\0' to end the directory string .
      */
     if (i > 0) {
-        directory    = strdup(file);
+        directory    = gmx_strdup(file);
         directory[i] = '\0';
-        fn           = strdup(file+i+1);
+        fn           = gmx_strdup(file+i+1);
     }
     else {
-        directory    = strdup(".");
-        fn           = strdup(file);
+        directory    = gmx_strdup(".");
+        fn           = gmx_strdup(file);
     }
     do {
         sprintf(buf,"%s/#%s.%d#",directory,fn,count);
@@ -870,7 +870,7 @@ char *low_gmxlibfn(const char *file, gmx_bool bAddCWD, gmx_bool bFatal)
     ret = NULL;
     if (bAddCWD && gmx_fexist(file))
     {
-        ret = strdup(file);
+        ret = gmx_strdup(file);
     }
     else 
     {
@@ -881,7 +881,7 @@ char *low_gmxlibfn(const char *file, gmx_bool bAddCWD, gmx_bool bFatal)
             sprintf(buf,"%s%c%s",dir,DIR_SEPARATOR,file);
             if (gmx_fexist(buf))
             {
-                ret = strdup(buf);
+                ret = gmx_strdup(buf);
             }
         }
         if (ret == NULL && bFatal) 
index 1fda20bbf7918bfa55c3fc52038492de8ec48ac0..b91482f421aefbc279319c22bcfcf580763cf169 100644 (file)
@@ -235,13 +235,13 @@ void gmx_log_open(const char *lognm,const t_commrec *cr,gmx_bool bMasterOnly,
         }
         else
         {
-            tmpnm=strdup(lognm);
+            tmpnm=gmx_strdup(lognm);
         }
         gmx_bcast(len*sizeof(*tmpnm),tmpnm,cr);
     }
     else
     {
-        tmpnm=strdup(lognm);
+        tmpnm=gmx_strdup(lognm);
     }
   
     debug_gmx();
@@ -440,7 +440,7 @@ void init_multisystem(t_commrec *cr,int nsim, int nfile,
                 ftp = fn2ftp(fnm[i].fns[0]);
                 par_fn(fnm[i].fns[0],ftp,cr,TRUE,FALSE,buf,255);
                 sfree(fnm[i].fns[0]);
-                fnm[i].fns[0] = strdup(buf);
+                fnm[i].fns[0] = gmx_strdup(buf);
             }
         }
     }
index 4d27bfb609706adb3c4863cdbcae466c28bbd887..8038bed8f69c088fd12464e46e75361aeb44d95a 100644 (file)
@@ -53,7 +53,7 @@ char *replace(const char *string,const char *search,const char *replace)
   stringlen=strlen(string);
   if ((string == NULL) || (slen == 0) || (stringlen == 0)) {
     if (string)
-      buf=strdup(string);
+      buf=gmx_strdup(string);
     return buf;
   }
   rlen=strlen(replace);
@@ -97,7 +97,7 @@ char *replaceww(const char *string,const char *search,const char *replace)
   stringlen=strlen(string);
   if ((string == NULL) || (searchlen == 0) || (stringlen == 0)) {
     if (string)
-      buf=strdup(string);
+      buf=gmx_strdup(string);
     return buf;
   }  
   replacelen=strlen(replace);
index f783d9464ce09bdf9dc8b7e592a8d0976f71c472..c56958363e2848cff26158f5a4ebc13284ecafd9 100644 (file)
@@ -252,7 +252,7 @@ static char *repall(const char *s,int nsr,const t_sandr_const sa[])
   /* Copy input to a non-constant char buffer.
    * buf1 is allocated here 
    */
-  buf1=strdup(s); 
+  buf1=gmx_strdup(s); 
   
   for(i=0; (i<nsr); i++) {
     /* Replace in buffer1, put result in buffer2.
@@ -274,7 +274,7 @@ static char *repallww(const char *s,int nsr,const t_sandr sa[])
   /* Copy input to a non-constant char buffer.
    * buf1 is allocated here 
    */
-  buf1=strdup(s); 
+  buf1=gmx_strdup(s); 
   
   for(i=0; (i<nsr); i++) {
     /* Replace in buffer1, put result in buffer2.
@@ -298,12 +298,12 @@ static char *html_xref(char *s,const char *program, t_linkdata *links,gmx_bool b
     snew(links->sr,n);
     for(i=0,j=0; (i<n); i++) {
       if (!program || (gmx_strcasecmp(program,filestr[i])  != 0)) {
-       links->sr[j].search=strdup(filestr[i]);
+       links->sr[j].search=gmx_strdup(filestr[i]);
        if (bWiki)
          sprintf(buf,"[[%s]]",filestr[i]);
        else
          sprintf(buf,"<a href=\"%s.html\">%s</a>",filestr[i],filestr[i]);
-       links->sr[j].replace=strdup(buf);
+       links->sr[j].replace=gmx_strdup(buf);
        j++;
       }
     }