Changeset 920c70 for src/helpers.cpp


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/helpers.cpp

    r87b597 r920c70  
    5858int CountLinesinFile(ifstream &InputFile)
    5959{
    60   char *buffer = Malloc<char>(MAXSTRINGSIZE, "CountLinesinFile: *buffer");
     60  char *buffer = new char[MAXSTRINGSIZE];
    6161  int lines=0;
    6262
     
    7070  }
    7171  InputFile.seekg(PositionMarker, ios::beg);
    72   Free(&buffer);
     72  delete[](buffer);
    7373  return lines;
    7474};
     
    9090  }
    9191  // allocate string
    92   returnstring = Malloc<char>(order + 2, "FixedDigitNumber: *returnstring");
     92  returnstring = new char[order + 2];
    9393  // terminate  and fill string array from end backward
    9494  returnstring[order] = '\0';
     
    122122double * ReturnFullMatrixforSymmetric(const double * const symm)
    123123{
    124   double *matrix = Malloc<double>(NDIM * NDIM, "molecule::ReturnFullMatrixforSymmetric: *matrix");
     124  double *matrix = new double[NDIM * NDIM];
    125125  matrix[0] = symm[0];
    126126  matrix[1] = symm[1];
     
    140140double * InverseMatrix( const double * const A)
    141141{
    142   double *B = Malloc<double>(NDIM * NDIM, "Vector::InverseMatrix: *B");
     142  double *B = new double[NDIM * NDIM];
    143143  double detA = RDET3(A);
    144144  double detAReci;
     
    196196
    197197  if (buffer != NULL) {
    198     MemoryUsageObserver::getInstance()->addMemory(buffer, size);
     198    //MemoryUsageObserver::getInstance()->addMemory(buffer, size);
    199199  } else {
    200200    Log() << Verbose(0) << "Malloc for datatype " << typeid(char).name()
     
    206206
    207207/**
    208  * Frees all memory registered by the memory observer and calls exit(225) afterwards.
     208 * Calls exit(255).
    209209 */
    210210void performCriticalExit() {
    211 //  map<void*, size_t> pointers = MemoryUsageObserver::getInstance()->getPointersToAllocatedMemory();
    212 //  for (map<void*, size_t>::iterator runner = pointers.begin(); runner != pointers.end(); runner++) {
    213 //    Free(((void**) &runner->first));
    214 //  }
    215 
    216211  exit(255);
    217212}
Note: See TracChangeset for help on using the changeset viewer.