Changeset 41194a for src/config.cpp
- Timestamp:
- Oct 5, 2009, 2:35:06 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, 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:
- c0917c
- Parents:
- 0227a9 (diff), c30180 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/config.cpp
r0227a9 r41194a 6 6 7 7 #include "config.hpp" 8 #include "memoryallocator.hpp" 8 9 9 10 /******************************** Functions for class ConfigFileBuffer **********************/ … … 86 87 return; 87 88 } else 88 buffer = (char **) Malloc(sizeof(char *)*NoLines, "ConfigFileBuffer::ConfigFileBuffer: **buffer");89 buffer = Malloc<char*>(NoLines, "ConfigFileBuffer::ConfigFileBuffer: **buffer"); 89 90 90 91 // scan each line and put into buffer … … 92 93 int i; 93 94 do { 94 buffer[lines] = (char *) Malloc(sizeof(char)*MAXSTRINGSIZE, "ConfigFileBuffer::ConfigFileBuffer: *buffer[]");95 buffer[lines] = Malloc<char>(MAXSTRINGSIZE, "ConfigFileBuffer::ConfigFileBuffer: *buffer[]"); 95 96 file->getline(buffer[lines], MAXSTRINGSIZE-1); 96 97 i = strlen(buffer[lines]); … … 112 113 { 113 114 for(int i=0;i<NoLines;++i) 114 Free( (void **)&buffer[i], "ConfigFileBuffer::~ConfigFileBuffer: *buffer[]");115 Free( (void **)&buffer, "ConfigFileBuffer::~ConfigFileBuffer: **buffer");116 Free( (void **)&LineMapping, "ConfigFileBuffer::~ConfigFileBuffer: *LineMapping");115 Free(&buffer[i]); 116 Free(&buffer); 117 Free(&LineMapping); 117 118 } 118 119 … … 122 123 void ConfigFileBuffer::InitMapping() 123 124 { 124 LineMapping = (int *) Malloc(sizeof(int)*NoLines, "ConfigFileBuffer::InitMapping: *LineMapping");125 LineMapping = Malloc<int>(NoLines, "ConfigFileBuffer::InitMapping: *LineMapping"); 125 126 for (int i=0;i<NoLines;i++) 126 127 LineMapping[i] = i; … … 163 164 config::config() 164 165 { 165 mainname = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: mainname");166 defaultpath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: defaultpath");167 pseudopotpath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: pseudopotpath");168 databasepath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: databasepath");169 configpath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: configpath");170 configname = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: configname");171 ThermostatImplemented = (int *) Malloc((MaxThermostats)*(sizeof(int)), "config constructor: *ThermostatImplemented");172 ThermostatNames = (char **) Malloc((MaxThermostats)*(sizeof(char *)), "config constructor: *ThermostatNames");166 mainname = Malloc<char>(MAXSTRINGSIZE,"config constructor: mainname"); 167 defaultpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: defaultpath"); 168 pseudopotpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: pseudopotpath"); 169 databasepath = Malloc<char>(MAXSTRINGSIZE,"config constructor: databasepath"); 170 configpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: configpath"); 171 configname = Malloc<char>(MAXSTRINGSIZE,"config constructor: configname"); 172 ThermostatImplemented = Malloc<int>(MaxThermostats, "config constructor: *ThermostatImplemented"); 173 ThermostatNames = Malloc<char*>(MaxThermostats, "config constructor: *ThermostatNames"); 173 174 for (int j=0;j<MaxThermostats;j++) 174 ThermostatNames[j] = (char *) MallocString(12*(sizeof(char)), "config constructor: ThermostatNames[]");175 ThermostatNames[j] = Malloc<char>(12, "config constructor: ThermostatNames[]"); 175 176 Thermostat = 4; 176 177 alpha = 0.; … … 263 264 config::~config() 264 265 { 265 Free( (void **)&mainname, "config::~config: *mainname");266 Free( (void **)&defaultpath, "config::~config: *defaultpath");267 Free( (void **)&pseudopotpath, "config::~config: *pseudopotpath");268 Free( (void **)&databasepath, "config::~config: *databasepath");269 Free( (void **)&configpath, "config::~config: *configpath");270 Free( (void **)&configname, "config::~config: *configname");271 Free( (void **)&ThermostatImplemented, "config::~config: *ThermostatImplemented");266 Free(&mainname); 267 Free(&defaultpath); 268 Free(&pseudopotpath); 269 Free(&databasepath); 270 Free(&configpath); 271 Free(&configname); 272 Free(&ThermostatImplemented); 272 273 for (int j=0;j<MaxThermostats;j++) 273 Free( (void **)&ThermostatNames[j], "config::~config: *ThermostatNames[]");274 Free( (void **)&ThermostatNames, "config::~config: **ThermostatNames");274 Free(&ThermostatNames[j]); 275 Free(&ThermostatNames); 275 276 }; 276 277 … … 280 281 void config::InitThermostats(class ConfigFileBuffer *fb) 281 282 { 282 char *thermo = Malloc String(12, "IonsInitRead: thermo");283 char *thermo = Malloc<char>(12, "IonsInitRead: thermo"); 283 284 int verbose = 0; 284 285 … … 347 348 Thermostat = None; 348 349 } 349 Free( (void **)&thermo, "InitThermostats: thermo");350 Free(&thermo); 350 351 }; 351 352 … … 1533 1534 long file_position = file->tellg(); // mark current position 1534 1535 char *dummy1, *dummy, *free_dummy; // pointers in the line that is read in per step 1535 dummy1 = free_dummy = (char *) Malloc(256 * sizeof(char), "config::ParseForParameter: *free_dummy");1536 dummy1 = free_dummy = Malloc<char>(256, "config::ParseForParameter: *free_dummy"); 1536 1537 1537 1538 //fprintf(stderr,"Parsing for %s\n",name); … … 1548 1549 if (file->eof()) { 1549 1550 if ((critical) && (found == 0)) { 1550 Free( (void **)&free_dummy, "config::ParseForParameter: *free_dummy");1551 Free(&free_dummy); 1551 1552 //Error(InitReading, name); 1552 1553 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); … … 1556 1557 file->clear(); 1557 1558 file->seekg(file_position, ios::beg); // rewind to start position 1558 Free( (void **)&free_dummy, "config::ParseForParameter: *free_dummy");1559 Free(&free_dummy); 1559 1560 return 0; 1560 1561 } … … 1608 1609 if (file->eof()) { 1609 1610 if ((critical) && (found == 0)) { 1610 Free( (void **)&free_dummy, "config::ParseForParameter: *free_dummy");1611 Free(&free_dummy); 1611 1612 //Error(InitReading, name); 1612 1613 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); … … 1616 1617 file->clear(); 1617 1618 file->seekg(file_position, ios::beg); // rewind to start position 1618 Free( (void **)&free_dummy, "config::ParseForParameter: *free_dummy");1619 Free(&free_dummy); 1619 1620 return 0; 1620 1621 } … … 1657 1658 if (critical) { 1658 1659 if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name); 1659 Free( (void **)&free_dummy, "config::ParseForParameter: *free_dummy");1660 Free(&free_dummy); 1660 1661 //return 0; 1661 1662 exit(255); … … 1665 1666 file->clear(); 1666 1667 file->seekg(file_position, ios::beg); // rewind to start position 1667 Free( (void **)&free_dummy, "config::ParseForParameter: *free_dummy");1668 Free(&free_dummy); 1668 1669 return 0; 1669 1670 } … … 1678 1679 file->seekg(file_position, ios::beg); // rewind to start position 1679 1680 } 1680 Free( (void **)&free_dummy, "config::ParseForParameter: *free_dummy");1681 Free(&free_dummy); 1681 1682 return 0; 1682 1683 } … … 1732 1733 } 1733 1734 } 1734 if ((type >= row_int) && (verbose)) fprintf(stderr,"\n"); 1735 Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); 1735 if ((type >= row_int) && (verbose)) 1736 fprintf(stderr,"\n"); 1737 Free(&free_dummy); 1736 1738 if (!sequential) { 1737 1739 file->clear(); … … 1811 1813 dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword) 1812 1814 //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name); 1813 //Free( (void **)&free_dummy);1815 //Free(&free_dummy); 1814 1816 //Error(FileOpenParams, NULL); 1815 1817 } else {
Note:
See TracChangeset
for help on using the changeset viewer.