[Deoptim-commits] r116 - pkg/DEoptim/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Feb 14 14:36:39 CET 2014


Author: bodanker
Date: 2014-02-14 14:36:39 +0100 (Fri, 14 Feb 2014)
New Revision: 116

Modified:
   pkg/DEoptim/src/de4_0.c
Log:
- fix another potential un/protect mis-match (for sexp_t_tmpC this time)


Modified: pkg/DEoptim/src/de4_0.c
===================================================================
--- pkg/DEoptim/src/de4_0.c	2014-02-13 17:28:49 UTC (rev 115)
+++ pkg/DEoptim/src/de4_0.c	2014-02-14 13:36:39 UTC (rev 116)
@@ -423,7 +423,6 @@
 
     /*------Trial mutation now in t_tmpP-----------------*/
     /* evaluate mutated population */
-    if(i_iter > 1) UNPROTECT(1);  // previous iteration's sexp_t_tmpC
     PROTECT(sexp_map_pop = popEvaluate(l_nfeval, sexp_t_tmpP,  fnMap, rho, 0));
     memmove(REAL(sexp_t_tmpP), REAL(sexp_map_pop), i_NP * i_D * sizeof(double)); // valgrind reports memory overlap here
     UNPROTECT(1);  // sexp_map_pop
@@ -458,6 +457,7 @@
 
       }
     } /* End mutation loop through ensemble */
+    UNPROTECT(1);  // sexp_t_tmpC
 
     if (d_c > 0) { /* calculate new meanCR and meanF */
       meanCR = (1-d_c)*meanCR + d_c*goodCR;
@@ -555,7 +555,7 @@
   *gt_bestC = t_bestC;
 
   PutRNGstate();
-  UNPROTECT(P+1); // +1 is for last iteration's sexp_t_tmpC
+  UNPROTECT(P);
 
 }
 



More information about the Deoptim-commits mailing list