Changeset 920c70 for src/builder.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/builder.cpp

    r87b597 r920c70  
    17501750                  delete(Subgraphs);
    17511751                  for (int i=0;i<FragmentCounter;i++)
    1752                     Free(&ListOfLocalAtoms[i]);
    1753                   Free(&ListOfLocalAtoms);
     1752                    delete[](ListOfLocalAtoms[i]);
     1753                  delete[](ListOfLocalAtoms);
    17541754                }
    17551755                delete(BackEdgeStack);
     
    18831883                            counter++;
    18841884                          }
    1885                           bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives");
     1885                          bool *Actives = new bool[counter];
    18861886                          counter = 0;
    18871887                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
     
    19111911                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++)
    19121912                            (*BigFinder)->ActiveFlag = Actives[counter++];
    1913                           Free(&Actives);
     1913                          delete[](Actives);
    19141914                          delete(LCList);
    19151915                          delete(TesselStruct);
     
    24432443void cleanUp(){
    24442444  World::purgeInstance();
    2445   Log() << Verbose(0) <<  "Maximum of allocated memory: "
    2446     << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl;
    2447   Log() << Verbose(0) <<  "Remaining non-freed memory: "
    2448     << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;
    2449   MemoryUsageObserver::purgeInstance();
    24502445  logger::purgeInstance();
    24512446  errorLogger::purgeInstance();
     
    24972492      ExitFlag = ParseCommandLineOptions(argc,argv,World::getInstance().getMolecules(),World::getInstance().getPeriode(),*World::getInstance().getConfig(), &ConfigFileName, ArgcList);
    24982493      // copy all remaining arguments to a new argv
    2499       Arguments = Malloc<char *>(ArgcList.size(), "main - **Arguments");
     2494      Arguments = new char *[ArgcList.size()];
    25002495      cout << "The following arguments are handled by CommandLineParser: ";
    25012496      for (set<int>::iterator ArgcRunner = ArgcList.begin(); ArgcRunner != ArgcList.end(); ++ArgcRunner) {
    2502         Arguments[ArgcSize] = Malloc<char>(strlen(argv[*ArgcRunner])+2, "main - *Arguments[]");
     2497        Arguments[ArgcSize] = new char[strlen(argv[*ArgcRunner])+2];
    25032498        strcpy(Arguments[ArgcSize], argv[*ArgcRunner]);
    25042499        cout << " " << argv[*ArgcRunner];
     
    25362531  if (ArgumentsCopied) {
    25372532    for (int i=0; i<ArgcSize;i++)
    2538       Free(&Arguments[i]);
    2539     Free(&Arguments);
     2533      delete[](Arguments[i]);
     2534    delete[](Arguments);
    25402535  }
    25412536  delete[](ConfigFileName);
Note: See TracChangeset for help on using the changeset viewer.