Changeset 920c70 for src/config.cpp
- Timestamp:
- May 31, 2010, 1:09:58 PM (16 years ago)
- 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
- File:
-
- 1 edited
-
src/config.cpp (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/config.cpp
r87b597 r920c70 93 93 return; 94 94 } else 95 buffer = Malloc<char*>(NoLines, "ConfigFileBuffer::ConfigFileBuffer: **buffer");95 buffer = new char *[NoLines]; 96 96 97 97 // scan each line and put into buffer … … 99 99 int i; 100 100 do { 101 buffer[lines] = Malloc<char>(MAXSTRINGSIZE, "ConfigFileBuffer::ConfigFileBuffer: *buffer[]");101 buffer[lines] = new char[MAXSTRINGSIZE]; 102 102 file->getline(buffer[lines], MAXSTRINGSIZE-1); 103 103 i = strlen(buffer[lines]); … … 119 119 { 120 120 for(int i=0;i<NoLines;++i) 121 Free(&buffer[i]);122 Free(&buffer);123 Free(&LineMapping);121 delete[](buffer[i]); 122 delete[](buffer); 123 delete[](LineMapping); 124 124 } 125 125 … … 129 129 void ConfigFileBuffer::InitMapping() 130 130 { 131 LineMapping = Malloc<int>(NoLines, "ConfigFileBuffer::InitMapping: *LineMapping");131 LineMapping = new int[NoLines]; 132 132 for (int i=0;i<NoLines;i++) 133 133 LineMapping[i] = i; … … 179 179 MaxLevel(5), RiemannTensor(0), LevRFactor(0), RiemannLevel(0), Lev0Factor(2), RTActualUse(0), AddPsis(0), RCut(20.), StructOpt(0), IsAngstroem(1), RelativeCoord(0), 180 180 MaxTypes(0) { 181 mainname = Malloc<char>(MAXSTRINGSIZE,"config constructor: mainname");182 defaultpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: defaultpath");183 pseudopotpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: pseudopotpath");184 databasepath = Malloc<char>(MAXSTRINGSIZE,"config constructor: databasepath");185 configpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: configpath");186 configname = Malloc<char>(MAXSTRINGSIZE,"config constructor: configname");181 mainname = new char[MAXSTRINGSIZE]; 182 defaultpath = new char[MAXSTRINGSIZE]; 183 pseudopotpath = new char[MAXSTRINGSIZE]; 184 databasepath = new char[MAXSTRINGSIZE]; 185 configpath = new char[MAXSTRINGSIZE]; 186 configname = new char[MAXSTRINGSIZE]; 187 187 strcpy(mainname,"pcp"); 188 188 strcpy(defaultpath,"not specified"); … … 199 199 config::~config() 200 200 { 201 Free(&mainname);202 Free(&defaultpath);203 Free(&pseudopotpath);204 Free(&databasepath);205 Free(&configpath);206 Free(&configname);207 Free(&ThermostatImplemented);201 delete[](mainname); 202 delete[](defaultpath); 203 delete[](pseudopotpath); 204 delete[](databasepath); 205 delete[](configpath); 206 delete[](configname); 207 delete[](ThermostatImplemented); 208 208 for (int j=0;j<MaxThermostats;j++) 209 Free(&ThermostatNames[j]);210 Free(&ThermostatNames);209 delete[](ThermostatNames[j]); 210 delete[](ThermostatNames); 211 211 212 212 if (BG != NULL) … … 218 218 void config::InitThermostats() 219 219 { 220 ThermostatImplemented = Malloc<int>(MaxThermostats, "config constructor: *ThermostatImplemented");221 ThermostatNames = Malloc<char*>(MaxThermostats, "config constructor: *ThermostatNames");220 ThermostatImplemented = new int[MaxThermostats]; 221 ThermostatNames = new char *[MaxThermostats]; 222 222 for (int j=0;j<MaxThermostats;j++) 223 ThermostatNames[j] = Malloc<char>(12, "config constructor: ThermostatNames[]");223 ThermostatNames[j] = new char[12]; 224 224 225 225 strcpy(ThermostatNames[0],"None"); … … 242 242 void config::ParseThermostats(class ConfigFileBuffer * const fb) 243 243 { 244 char * const thermo = Malloc<char>(12, "IonsInitRead: thermo");244 char * const thermo = new char[12]; 245 245 const int verbose = 0; 246 246 … … 309 309 Thermostat = None; 310 310 } 311 Free(thermo);311 delete[](thermo); 312 312 }; 313 313 … … 1562 1562 for (MoleculeList::const_iterator Runner = MolList->ListOfMolecules.begin(); Runner != MolList->ListOfMolecules.end(); Runner++) { 1563 1563 Walker = (*Runner)->start; 1564 int *elementNo = Calloc<int>(MAX_ELEMENTS, "config::SavePDB - elementNo"); 1564 int *elementNo = new int[MAX_ELEMENTS]; 1565 for (int i=0;i<MAX_ELEMENTS;i++) 1566 elementNo[i] = 0; 1565 1567 AtomNo = 0; 1566 1568 while (Walker->next != (*Runner)->end) { … … 1585 1587 AtomNo++; 1586 1588 } 1587 Free(&elementNo);1589 delete[](elementNo); 1588 1590 MolNo++; 1589 1591 } … … 1604 1606 FILE *f = NULL; 1605 1607 1606 int *elementNo = Calloc<int>(MAX_ELEMENTS, "config::SavePDB - elementNo"); 1608 int *elementNo = new int[MAX_ELEMENTS]; 1609 for (int i=0;i<MAX_ELEMENTS;i++) 1610 elementNo[i] = 0; 1607 1611 char name[MAXSTRINGSIZE]; 1608 1612 strncpy(name, filename, MAXSTRINGSIZE-1); … … 1611 1615 if (f == NULL) { 1612 1616 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl); 1613 Free(&elementNo);1617 delete[](elementNo); 1614 1618 return false; 1615 1619 } … … 1640 1644 } 1641 1645 fclose(f); 1642 Free(&elementNo);1646 delete[](elementNo); 1643 1647 1644 1648 return true; … … 1734 1738 1735 1739 // create global to local id map 1736 int **LocalNotoGlobalNoMap = Calloc<int *>(MolList->ListOfMolecules.size(), "config::SaveTREMOLO - **LocalNotoGlobalNoMap"); 1740 int **LocalNotoGlobalNoMap = new int *[MolList->ListOfMolecules.size()]; 1741 for (int i=0;i<MolList->ListOfMolecules.size();i++) 1742 LocalNotoGlobalNoMap[i] = NULL; 1737 1743 { 1738 1744 int MolCounter = 0; 1739 1745 int AtomNo = 0; 1740 1746 for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) { 1741 LocalNotoGlobalNoMap[MolCounter] = Calloc<int>(MolList->CountAllAtoms(), "config::SaveTREMOLO - *LocalNotoGlobalNoMap[]"); 1747 LocalNotoGlobalNoMap[MolCounter] = new int[MolList->CountAllAtoms()]; 1748 for (int i=0;i<MolList->CountAllAtoms();i++) 1749 LocalNotoGlobalNoMap[MolCounter][i] = NULL; 1742 1750 1743 1751 (*MolWalker)->SetIndexedArrayForEachAtomTo( LocalNotoGlobalNoMap[MolCounter], &atom::nr, IncrementalAbsoluteValue, &AtomNo); … … 1779 1787 delete(fname); 1780 1788 for(size_t i=0;i<MolList->ListOfMolecules.size(); i++) 1781 Free(&LocalNotoGlobalNoMap[i]);1782 Free(&LocalNotoGlobalNoMap);1789 delete[](LocalNotoGlobalNoMap[i]); 1790 delete[](LocalNotoGlobalNoMap); 1783 1791 1784 1792 return true; … … 1938 1946 char *dummy1 = NULL; 1939 1947 char *dummy = NULL; 1940 char * const free_dummy = Malloc<char>(256, "config::ParseForParameter: *free_dummy"); // pointers in the line that is read in per step1948 char free_dummy[MAXSTRINGSIZE]; // pointers in the line that is read in per step 1941 1949 dummy1 = free_dummy; 1942 1950 … … 1954 1962 if (file->eof()) { 1955 1963 if ((critical) && (found == 0)) { 1956 Free(free_dummy);1957 1964 //Error(InitReading, name); 1958 1965 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); … … 1962 1969 file->clear(); 1963 1970 file->seekg(file_position, ios::beg); // rewind to start position 1964 Free(free_dummy);1965 1971 return 0; 1966 1972 } … … 1993 1999 dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword) 1994 2000 //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name); 1995 //Free((void **)&free_dummy);1996 2001 //Error(FileOpenParams, NULL); 1997 2002 } else { … … 2014 2019 if (file->eof()) { 2015 2020 if ((critical) && (found == 0)) { 2016 Free(free_dummy);2017 2021 //Error(InitReading, name); 2018 2022 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); … … 2022 2026 file->clear(); 2023 2027 file->seekg(file_position, ios::beg); // rewind to start position 2024 Free(free_dummy);2025 2028 return 0; 2026 2029 } … … 2063 2066 if (critical) { 2064 2067 if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name); 2065 Free(free_dummy);2066 2068 //return 0; 2067 2069 exit(255); … … 2071 2073 file->clear(); 2072 2074 file->seekg(file_position, ios::beg); // rewind to start position 2073 Free(free_dummy);2074 2075 return 0; 2075 2076 } … … 2084 2085 file->seekg(file_position, ios::beg); // rewind to start position 2085 2086 } 2086 Free(free_dummy);2087 2087 return 0; 2088 2088 } … … 2140 2140 if ((type >= row_int) && (verbose)) 2141 2141 fprintf(stderr,"\n"); 2142 Free(free_dummy);2143 2142 if (!sequential) { 2144 2143 file->clear(); … … 2221 2220 dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword) 2222 2221 //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name); 2223 //Free(&free_dummy);2224 2222 //Error(FileOpenParams, NULL); 2225 2223 } else {
Note:
See TracChangeset
for help on using the changeset viewer.
