Ignore:
Timestamp:
May 31, 2010, 1:09:58 PM (16 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, Candidate_v1.7.0, 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:
42af9e
Parents:
87b597
Message:

Removed all Malloc/Calloc/ReAlloc (&Free) and replaced by new and delete/delete[].

Due to the new MemDebug framework there is no need (or even unnecessary/unwanted competition between it and) for the MemoryAllocator and ..UsageObserver anymore.
They can however still be used with c codes such as pcp and alikes.

In Molecuilder lots of glibc corruptions arose and the C-like syntax make it generally harder to get allocation and deallocation straight.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_dynamics.cpp

    r87b597 r920c70  
    190190{
    191191  stringstream zeile1, zeile2;
    192   int *DoubleList = Calloc<int>(AtomCount, "PrintPermutationMap: *DoubleList");
     192  int *DoubleList = new int[AtomCount];
     193  for(int i=0;i<AtomCount;i++)
     194    DoubleList[i] = 0;
    193195  int doubles = 0;
    194196  zeile1 << "PermutationMap: ";
     
    204206  if (doubles >0)
    205207    DoLog(2) && (Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl);
    206   Free(&DoubleList);
     208  delete[](DoubleList);
    207209//  Log() << Verbose(2) << zeile1.str() << endl << zeile2.str() << endl;
    208210};
     
    339341  double Potential, OldPotential, OlderPotential;
    340342  struct EvaluatePotential Params;
    341   Params.PermutationMap = Calloc<atom*>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.**PermutationMap");
    342   Params.DistanceList = Malloc<DistanceMap*>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.**DistanceList");
    343   Params.DistanceIterators = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*DistanceIterators");
    344   Params.DoubleList = Calloc<int>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*DoubleList");
    345   Params.StepList = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*StepList");
     343  Params.PermutationMap = new atom *[AtomCount];
     344  Params.DistanceList = new DistanceMap *[AtomCount];
     345  Params.DistanceIterators = new DistanceMap::iterator[AtomCount];
     346  Params.DoubleList = new int[AtomCount];
     347  Params.StepList = new DistanceMap::iterator[AtomCount];
    346348  int round;
    347349  atom *Walker = NULL, *Runner = NULL, *Sprinter = NULL;
    348350  DistanceMap::iterator Rider, Strider;
     351
     352  // set to zero
     353  for (int i=0;i<AtomCount;i++) {
     354    Params.PermutationMap[i] = NULL;
     355    Params.DoubleList[i] = 0;
     356  }
    349357
    350358  /// Minimise the potential
     
    363371  DoLog(1) && (Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl);
    364372  MakeInjectivePermutation(this, Params);
    365   Free(&Params.DoubleList);
     373  delete[](Params.DoubleList);
    366374
    367375  // argument minimise the constrained potential in this injective PermutationMap
     
    445453  for (int i=AtomCount; i--;)
    446454    Params.DistanceList[i]->clear();
    447   Free(&Params.DistanceList);
    448   Free(&Params.DistanceIterators);
     455  delete[](Params.DistanceList);
     456  delete[](Params.DistanceIterators);
    449457  return ConstrainedPotential(Params);
    450458};
     
    488496    MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem());
    489497  else {
    490     PermutationMap = Malloc<atom *>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: **PermutationMap");
     498    PermutationMap = new atom *[AtomCount];
    491499    SetIndexedArrayForEachAtomTo( PermutationMap, &atom::nr );
    492500  }
     
    523531
    524532  // store the list to single step files
    525   int *SortIndex = Malloc<int>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: *SortIndex");
     533  int *SortIndex = new int[AtomCount];
    526534  for (int i=AtomCount; i--; )
    527535    SortIndex[i] = i;
    528536  status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex);
     537  delete[](SortIndex);
    529538
    530539  // free and return
    531   Free(&PermutationMap);
     540  delete[](PermutationMap);
    532541  delete(MoleculePerStep);
    533542  return status;
     
    590599      ConstrainedPotentialEnergy = MinimiseConstrainedPotential(PermutationMap,configuration.DoConstrainedMD, 0, configuration.GetIsAngstroem());
    591600      EvaluateConstrainedForces(configuration.DoConstrainedMD, 0, PermutationMap, &Force);
    592       Free(&PermutationMap);
     601      delete[](PermutationMap);
    593602    }
    594603
Note: See TracChangeset for help on using the changeset viewer.