Fixed valgrind issues.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
parent
208bb097dd
commit
5b1c73a2af
|
@ -39,9 +39,8 @@ namespace CreatureLib::Battling {
|
||||||
free(_memory);
|
free(_memory);
|
||||||
if (_currentThread != nullptr && _currentThread->joinable()) {
|
if (_currentThread != nullptr && _currentThread->joinable()) {
|
||||||
_currentThread->join();
|
_currentThread->join();
|
||||||
delete _currentThread;
|
|
||||||
_currentThread = nullptr;
|
|
||||||
}
|
}
|
||||||
|
delete _currentThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t GetPosition() const noexcept { return _offset; }
|
size_t GetPosition() const noexcept { return _offset; }
|
||||||
|
@ -52,9 +51,9 @@ namespace CreatureLib::Battling {
|
||||||
return;
|
return;
|
||||||
if (_currentThread != nullptr && _currentThread->joinable()) {
|
if (_currentThread != nullptr && _currentThread->joinable()) {
|
||||||
_currentThread->join();
|
_currentThread->join();
|
||||||
delete _currentThread;
|
|
||||||
_currentThread = nullptr;
|
|
||||||
}
|
}
|
||||||
|
delete _currentThread;
|
||||||
|
|
||||||
if (_offset + sizeof(T) >= _capacity) {
|
if (_offset + sizeof(T) >= _capacity) {
|
||||||
_capacity += stepSize;
|
_capacity += stepSize;
|
||||||
auto newPtr = realloc(_memory, _capacity);
|
auto newPtr = realloc(_memory, _capacity);
|
||||||
|
@ -74,10 +73,10 @@ namespace CreatureLib::Battling {
|
||||||
void FinishListening() {
|
void FinishListening() {
|
||||||
if (_currentThread != nullptr && _currentThread->joinable()) {
|
if (_currentThread != nullptr && _currentThread->joinable()) {
|
||||||
_currentThread->join();
|
_currentThread->join();
|
||||||
|
}
|
||||||
delete _currentThread;
|
delete _currentThread;
|
||||||
_currentThread = nullptr;
|
_currentThread = nullptr;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RunListeners(EventData* event) {
|
void RunListeners(EventData* event) {
|
||||||
|
|
|
@ -41,5 +41,6 @@ TEST_CASE("Build and use event hook with different types", "[Battling]") {
|
||||||
eventHook.Trigger<FaintEvent>(nullptr);
|
eventHook.Trigger<FaintEvent>(nullptr);
|
||||||
eventHook.Trigger<DamageEvent>(nullptr, DamageSource::AttackDamage, 0, 0);
|
eventHook.Trigger<DamageEvent>(nullptr, DamageSource::AttackDamage, 0, 0);
|
||||||
eventHook.Trigger<FaintEvent>(nullptr);
|
eventHook.Trigger<FaintEvent>(nullptr);
|
||||||
|
eventHook.FinishListening();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue