[Commits] [svn:einsteintoolkit] incoming/PITTNullCode/SphericalHarmonicReconASCII/src/ (Rev. 68)

reisswig at tapir.caltech.edu reisswig at tapir.caltech.edu
Sat May 26 16:14:22 CDT 2012


User: reisswig
Date: 2012/05/26 04:14 PM

Modified:
 /PITTNullCode/SphericalHarmonicReconASCII/src/
  startup.cc

Log:
 SphericalHarmonicReconASCII: Bela's patch to eliminate a segfault on exit.

File Changes:

Directory: /PITTNullCode/SphericalHarmonicReconASCII/src/
=========================================================

File [modified]: startup.cc
Delta lines: +9 -52
===================================================================
--- PITTNullCode/SphericalHarmonicReconASCII/src/startup.cc	2012-05-03 18:29:09 UTC (rev 67)
+++ PITTNullCode/SphericalHarmonicReconASCII/src/startup.cc	2012-05-26 21:14:22 UTC (rev 68)
@@ -329,59 +329,16 @@
       if (time_derivative_in_file && SHR::Ct[i]) delete SHR::Ct[i];
    }
 
-   // delete only those databases that were allocated
+   // there are multiple pointers pointing to the same class,
+   // make sure that each class is deleted only once
 
-   // get all different databases-names
-   vector<string> fnames;
-   fnames.push_back(file_gxx[0]);
-   fnames.push_back(file_gxy[0]);
-   fnames.push_back(file_gxz[0]);
-   fnames.push_back(file_gyy[0]);
-   fnames.push_back(file_gyz[0]);
-   fnames.push_back(file_gzz[0]);
-   fnames.push_back(file_shiftx[0]);
-   fnames.push_back(file_shifty[0]);
-   fnames.push_back(file_shiftz[0]);
-   fnames.push_back(file_lapse[0]);
-   fnames.push_back(file_gxx[1]);
-   fnames.push_back(file_gxy[1]);
-   fnames.push_back(file_gxz[1]);
-   fnames.push_back(file_gyy[1]);
-   fnames.push_back(file_gyz[1]);
-   fnames.push_back(file_gzz[1]);
-   fnames.push_back(file_shiftx[1]);
-   fnames.push_back(file_shifty[1]);
-   fnames.push_back(file_shiftz[1]);
-   fnames.push_back(file_lapse[1]);
-   fnames.push_back(file_gxx[2]);
-   fnames.push_back(file_gxy[2]);
-   fnames.push_back(file_gxz[2]);
-   fnames.push_back(file_gyy[2]);
-   fnames.push_back(file_gyz[2]);
-   fnames.push_back(file_gzz[2]);
-   fnames.push_back(file_shiftx[2]);
-   fnames.push_back(file_shifty[2]);
-   fnames.push_back(file_shiftz[2]);
-   fnames.push_back(file_lapse[2]);
-   
-   for (int i=0; i < 3*NUM_METRIC_COMPONENTS; ++i)
-   {
-      int found = -1;
-      for (int j=0; j < i; ++j)
-      {
-         if (fnames[i] == fnames[j]) 
-         {
-            found == j;
-            break;
-         }
-      }
-      if (found < 0)
-      {
-         delete SHR::db[i];
-         SHR::db[i] = NULL;
-      }
-      else
-         SHR::db[i] = NULL;
+   for(size_t i=0;i<SHR::db.size();++i) {
+     if(SHR::db[i]==0) continue;
+     for(size_t j=i+1;j<SHR::db.size();++j)
+       if(SHR::db[j]==SHR::db[i]) {
+         SHR::db[j]=0;
+       }
+     delete SHR::db[i]; SHR::db[i]=0;
    }
 }
 



More information about the Commits mailing list