[Avida-SVN] r1965 - branches/energy/source/main

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Mon Aug 20 11:53:12 PDT 2007


Author: beckma24
Date: 2007-08-20 14:53:11 -0400 (Mon, 20 Aug 2007)
New Revision: 1965

Modified:
   branches/energy/source/main/cPopulation.cc
Log:
Dave is the man.  Fixed memory leak in PrintDemeSpacialEnergy, and changed out to allow easy movie making

Modified: branches/energy/source/main/cPopulation.cc
===================================================================
--- branches/energy/source/main/cPopulation.cc	2007-08-20 17:27:17 UTC (rev 1964)
+++ branches/energy/source/main/cPopulation.cc	2007-08-20 18:53:11 UTC (rev 1965)
@@ -1741,11 +1741,11 @@
 // Write spatial energy data to a file that can easily be read into Matlab
 void cPopulation::PrintDemeSpatialEnergyData() const {
   int cellID = 0;
-  cString tmpfilename = "deme_spacial_energy.m";
-  cDataFile& df = m_world->GetDataFile(tmpfilename);
   int update = m_world->GetStats().GetUpdate();
   
   for(int i = 0; i < m_world->GetPopulation().GetNumDemes(); i++) {
+    cString tmpfilename = cStringUtil::Stringf( "deme_%07i_spacial_energy.m", i);  // moved here for easy movie making
+    cDataFile& df = m_world->GetDataFile(tmpfilename);
     cString UpdateStr = cStringUtil::Stringf( "deme_%07i_energy_%07i = [ ...", i, update );
     df.WriteRaw(UpdateStr);
 
@@ -1754,7 +1754,7 @@
 
     // write grid to file
     for (int j = 0; j < gridsize; j++) {
-      cPopulationCell cell = m_world->GetPopulation().GetCell(cellID);
+      cPopulationCell& cell = m_world->GetPopulation().GetCell(cellID);
       if(cell.IsOccupied()) {
         df.WriteBlockElement(cell.GetOrganism()->GetPhenotype().GetStoredEnergy(), j, xsize);
       } else {
@@ -1765,7 +1765,6 @@
     df.WriteRaw("];");
     df.Endl();
   }
-  m_world->GetDataFileManager().Remove(tmpfilename);
 }
 
 // Write spatial data to a file that can easily be read into Matlab




More information about the Avida-cvs mailing list