diff --git a/Source/Memory/Heap.cpp b/Source/Memory/Heap.cpp index 6670535f..fd74783c 100644 --- a/Source/Memory/Heap.cpp +++ b/Source/Memory/Heap.cpp @@ -85,6 +85,7 @@ namespace Aurora::Memory AuSPtr GetSelfReference() override; void TryRelease(); + void DecrementUsers(); void RequestTermination(); private: @@ -211,22 +212,35 @@ namespace Aurora::Memory { if (buffer == nullptr) return; o1heapFree(heap_, buffer); - count_--; + DecrementUsers(); + } + + void InternalHeap::DecrementUsers() + { + if (--count_ == 0) + { + AU_LOCK_GUARD(this->mutex_); + TryRelease(); + } } void InternalHeap::TryRelease() { - if (!isDangling_) return; + if (!isDangling_) + { + return; + } if (count_ == 0) { delete this; - return; } } void InternalHeap::RequestTermination() { + AU_LOCK_GUARD(this->mutex_); + if (count_) { LogWarn("Heap life was less than its allocations, waiting for final free"); diff --git a/Source/Time/Clock.cpp b/Source/Time/Clock.cpp index a70fb2c4..9e58820d 100644 --- a/Source/Time/Clock.cpp +++ b/Source/Time/Clock.cpp @@ -239,7 +239,7 @@ namespace Aurora::Time } else { - tm.tm_isdst = -1; // out of the 2 crts i've bothered checked, out of 3, this is legal + tm.tm_isdst = -1; // out of the 2 crts i've bothered to check, out of 3, this is legal timet = mktime(&tm); }