Skip to content

Commit

Permalink
trying out smart pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoPannetier committed Sep 10, 2024
1 parent 606fe0b commit 21ee698
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/BatchMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4955,7 +4955,7 @@ void setUpSpeciesTrait(vector<string> parameters) {
const bool isOutput = parameters[14] == "TRUE";

// Create species trait
SpeciesTrait* trait = new SpeciesTrait(
unique_ptr<SpeciesTrait> trait(new SpeciesTrait(
traitType, sex,
positions, expressionType,
initDist, initParams,
Expand All @@ -4964,7 +4964,7 @@ void setUpSpeciesTrait(vector<string> parameters) {
mutationDistribution, mutationParameters,
ploidy,
isOutput
);
));
pSpecies->addTrait(traitType, *trait);
}

Expand Down Expand Up @@ -6478,7 +6478,7 @@ void RunBatch(int nSimuls, int nLandscapes)
bool params_ok;
simParams sim = paramsSim->getSim();

Landscape* pLandscape = NULL; // pointer to landscape
Landscape* pLandscape = nullptr; // pointer to landscape

t0 = (int)time(0);

Expand All @@ -6503,7 +6503,7 @@ void RunBatch(int nSimuls, int nLandscapes)

for (int j = 0; j < nLandscapes; j++) {
// create new landscape
if (pLandscape != NULL) delete pLandscape;
if (pLandscape != nullptr) delete pLandscape;
pLandscape = new Landscape;
bool landOK = true;

Expand Down Expand Up @@ -6698,10 +6698,10 @@ void RunBatch(int nSimuls, int nLandscapes)
ifsTraits.clear();
}

if (pLandscape != NULL)
if (pLandscape != nullptr)
{
delete pLandscape;
pLandscape = NULL;
pLandscape = nullptr;
}

} // end of landOK condition
Expand Down
9 changes: 7 additions & 2 deletions src/RScore/Cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ unsigned long int Cell::getVisits(void) { return visits; }
// Initial species distribution cell functions

DistCell::DistCell(int xx, int yy) {
x = xx; y = yy; initialise = false;
x = xx;
y = yy;
initialise = false;
}

DistCell::~DistCell() {
Expand All @@ -201,7 +203,10 @@ bool DistCell::toInitialise(locn loc) {
bool DistCell::selected(void) { return initialise; }

locn DistCell::getLocn(void) {
locn loc; loc.x = x; loc.y = y; return loc;
locn loc;
loc.x = x;
loc.y = y;
return loc;
}

//---------------------------------------------------------------------------
Expand Down

0 comments on commit 21ee698

Please sign in to comment.