Skip to content

Commit

Permalink
Fix potential memory leak?
Browse files Browse the repository at this point in the history
  • Loading branch information
powerof3 committed Jan 16, 2024
1 parent 40c9c6b commit 1377568
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 42 deletions.
2 changes: 1 addition & 1 deletion SPID/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20)
set(NAME "po3_SpellPerkItemDistributor" CACHE STRING "")
set(VERSION 6.8.0 CACHE STRING "")
set(VERSION 6.8.1 CACHE STRING "")
set(AE_VERSION 1)
set(VR_VERSION 1)

Expand Down
2 changes: 1 addition & 1 deletion SPID/include/LookupNPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace NPC

struct Data
{
Data(RE::TESNPC* a_npc);
Data(RE::Actor* a_actor, RE::TESNPC* a_npc);
~Data() = default;

[[nodiscard]] RE::TESNPC* GetNPC() const;
[[nodiscard]] RE::Actor* GetActor() const;
Expand Down
11 changes: 5 additions & 6 deletions SPID/src/DistributeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,6 @@ namespace Distribute
}
}

void SetupDistribution()
{
// Clear logger's buffer to free some memory :)
buffered_logger::clear();
}

void Setup()
{
// Create tag keywords
Expand All @@ -140,6 +134,9 @@ namespace Distribute
PCLevelMult::Manager::Register();

DoInitialDistribution();

// Clear logger's buffer to free some memory :)
buffered_logger::clear();
}

void DoInitialDistribution()
Expand Down Expand Up @@ -200,6 +197,8 @@ namespace Distribute
}
}
}

sums.clear();
}
});
}
Expand Down
34 changes: 1 addition & 33 deletions SPID/src/LookupNPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,6 @@ namespace NPC
return formID == a_formID;
}

Data::Data(RE::TESNPC* a_npc) :
npc(a_npc),
actor(nullptr),
name(a_npc->GetName()),
race(a_npc->GetRace()),
level(a_npc->GetLevel()),
sex(a_npc->GetSex()),
unique(a_npc->IsUnique()),
summonable(a_npc->IsSummonable()),
child(race && (race->IsChildRace() || race->formEditorID.contains("RaceChild"))),
leveled(a_npc->UsesTemplate())
{
a_npc->ForEachKeyword([&](const RE::BGSKeyword* a_keyword) {
keywords.emplace(a_keyword->GetFormEditorID());
return RE::BSContainer::ForEachResult::kContinue;
});

if (race) {
race->ForEachKeyword([&](const RE::BGSKeyword* a_keyword) {
keywords.emplace(a_keyword->GetFormEditorID());
return RE::BSContainer::ForEachResult::kContinue;
});
}

IDs.emplace_back(a_npc);

std::call_once(init, [&] { potentialFollowerFaction = RE::TESForm::LookupByID<RE::TESFaction>(0x0005C84D); });
if (potentialFollowerFaction) {
teammate = a_npc->IsInFaction(potentialFollowerFaction);
}
}

Data::Data(RE::Actor* a_actor, RE::TESNPC* a_npc) :
npc(a_npc),
actor(a_actor),
Expand Down Expand Up @@ -101,7 +69,7 @@ namespace NPC
teammate = actor->IsPlayerTeammate() || potentialFollowerFaction && npc->IsInFaction(potentialFollowerFaction);
}

RE::TESNPC* Data::GetNPC() const
RE::TESNPC* Data::GetNPC() const
{
return npc;
}
Expand Down
2 changes: 1 addition & 1 deletion SPID/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spid",
"version-string": "6.8.0",
"version-string": "6.8.1",
"description": "Spell Perk Item Distributor",
"homepage": "https://github.com/powerof3/Spell-Perk-Item-Distributor",
"license": "MIT",
Expand Down

0 comments on commit 1377568

Please sign in to comment.