Changeset 920c70 for src/molecule.cpp


Ignore:
Timestamp:
May 31, 2010, 1:09: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:
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.cpp

    r87b597 r920c70  
    242242    Orthovector1.MatrixMultiplication(matrix);
    243243    InBondvector -= Orthovector1; // subtract just the additional translation
    244     Free(&matrix);
     244    delete[](matrix);
    245245    bondlength = InBondvector.Norm();
    246246//    Log() << Verbose(4) << "Corrected InBondvector is now: ";
     
    251251  InBondvector.Normalize();
    252252  // get typical bond length and store as scale factor for later
     253  ASSERT(TopOrigin->type != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");
    253254  BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1];
    254255  if (BondRescale == -1) {
     
    472473      break;
    473474  }
    474   Free(&matrix);
     475  delete[](matrix);
    475476
    476477//  Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;
     
    10341035  if (result) {
    10351036    DoLog(5) && (Log() << Verbose(5) << "Calculating distances" << endl);
    1036     Distances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances");
    1037     OtherDistances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances");
     1037    Distances = new double[AtomCount];
     1038    OtherDistances = new double[AtomCount];
    10381039    SetIndexedArrayForEachAtomTo ( Distances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity);
    10391040    SetIndexedArrayForEachAtomTo ( OtherDistances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity);
     1041    for(int i=0;i<AtomCount;i++) {
     1042      Distances[i] = 0.;
     1043      OtherDistances[i] = 0.;
     1044    }
    10401045
    10411046    /// ... sort each list (using heapsort (o(N log N)) from GSL)
    10421047    DoLog(5) && (Log() << Verbose(5) << "Sorting distances" << endl);
    1043     PermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermMap");
    1044     OtherPermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *OtherPermMap");
     1048    PermMap = new size_t[AtomCount];
     1049    OtherPermMap = new size_t[AtomCount];
     1050    for(int i=0;i<AtomCount;i++) {
     1051      PermMap[i] = 0;
     1052      OtherPermMap[i] = 0;
     1053    }
    10451054    gsl_heapsort_index (PermMap, Distances, AtomCount, sizeof(double), CompareDoubles);
    10461055    gsl_heapsort_index (OtherPermMap, OtherDistances, AtomCount, sizeof(double), CompareDoubles);
    1047     PermutationMap = Calloc<int>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermutationMap");
     1056    PermutationMap = new int[AtomCount];
     1057    for(int i=0;i<AtomCount;i++)
     1058      PermutationMap[i] = 0;
    10481059    DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl);
    10491060    for(int i=AtomCount;i--;)
     
    10601071
    10611072    // free memory
    1062     Free(&PermMap);
    1063     Free(&OtherPermMap);
    1064     Free(&Distances);
    1065     Free(&OtherDistances);
     1073    delete[](PermMap);
     1074    delete[](OtherPermMap);
     1075    delete[](Distances);
     1076    delete[](OtherDistances);
    10661077    if (flag) { // if not equal
    1067       Free(&PermutationMap);
     1078      delete[](PermutationMap);
    10681079      result = false;
    10691080    }
     
    10911102  atom *Walker = NULL, *OtherWalker = NULL;
    10921103  DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl);
    1093   int *AtomicMap = Malloc<int>(AtomCount, "molecule::GetAtomicMap: *AtomicMap");
     1104  int *AtomicMap = new int[AtomCount];
    10941105  for (int i=AtomCount;i--;)
    10951106    AtomicMap[i] = -1;
Note: See TracChangeset for help on using the changeset viewer.