Changeset 8e0c63 for src


Ignore:
Timestamp:
Jun 29, 2010, 3:37:58 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
56fb09, bdc91e
Parents:
ef7d30
git-author:
Frederik Heber <heber@…> (06/29/10 15:25:53)
git-committer:
Frederik Heber <heber@…> (06/29/10 15:37:58)
Message:

MEMFIX: MatrixContainer::MatrixContainer() made some initial allocations that were simply overwritten afterwards and not free'd.

  • This probably originates from the removal of Malloc/Free.
  • TESTFIX: Molecules/5 now returns 0 and not 134 anymore. (but still BROKEN as it seems)

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/parser.cpp

    ref7d30 r8e0c63  
    7676MatrixContainer::~MatrixContainer() {
    7777  if (Matrix != NULL) {
     78    // free Matrix[MatrixCounter]
     79    if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL))
     80      for(int j=RowCounter[MatrixCounter]+1;j--;)
     81        delete[](Matrix[MatrixCounter][j]);
     82    //if (MatrixCounter != 0)
     83    delete[](Matrix[MatrixCounter]);
     84    // free all matrices but ultimate one
    7885    for(int i=MatrixCounter;i--;) {
    7986      if ((ColumnCounter != NULL) && (RowCounter != NULL)) {
     
    8390      }
    8491    }
    85     if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL))
    86       for(int j=RowCounter[MatrixCounter]+1;j--;)
    87         delete[](Matrix[MatrixCounter][j]);
    88     if (MatrixCounter != 0)
    89       delete[](Matrix[MatrixCounter]);
    9092    delete[](Matrix);
    9193  }
     94  // free indices
    9295  if (Indices != NULL)
    9396    for(int i=MatrixCounter+1;i--;) {
     
    9699  delete[](Indices);
    97100 
     101  // free header and counters
    98102  if (Header != NULL)
    99103    for(int i=MatrixCounter+1;i--;)
     
    168172
    169173  // parse header
     174  if (Header[MatrixNr] != NULL)
     175    delete[] Header[MatrixNr];
    170176  Header[MatrixNr] = new char[1024];
    171177  for (int m=skiplines+1;m--;)
     
    207213  // allocate matrix if it's not zero dimension in one direction
    208214  if ((ColumnCounter[MatrixNr] > 0) && (RowCounter[MatrixNr] > -1)) {
     215    if (Matrix[MatrixNr] != NULL)
     216      delete[] Matrix[MatrixNr];
    209217    Matrix[MatrixNr] = new double*[RowCounter[MatrixNr] + 1];
    210  
     218    for(int j=0;j<RowCounter[MatrixNr]+1;j++)
     219      Matrix[MatrixNr][j] = 0;
     220
    211221    // parse in each entry for this matrix
    212222    input.clear();
     
    219229    strncpy(Header[MatrixNr], line.str().c_str(), 1023); 
    220230    for(int j=0;j<RowCounter[MatrixNr];j++) {
     231      if (Matrix[MatrixNr][j] != NULL)
     232        delete[] Matrix[MatrixNr][j];
    221233      Matrix[MatrixNr][j] = new double[ColumnCounter[MatrixNr]];
     234      for(int k=0;k<ColumnCounter[MatrixNr];k++)
     235        Matrix[MatrixNr][j][k] = 0;
     236
    222237      input.getline(filename, 1023);
    223238      stringstream lines(filename);
     
    229244        //Log() << Verbose(1) << " " << setprecision(2) << Matrix[MatrixNr][j][k] << endl;
    230245      }
     246      if (Matrix[MatrixNr][ RowCounter[MatrixNr] ] != NULL)
     247        delete[] Matrix[MatrixNr][ RowCounter[MatrixNr] ];
    231248      Matrix[MatrixNr][ RowCounter[MatrixNr] ] = new double[ColumnCounter[MatrixNr]];
    232249      for(int j=ColumnCounter[MatrixNr];j--;)
Note: See TracChangeset for help on using the changeset viewer.