Add Handles::clear() and run it on exit

This commit is contained in:
2025-10-09 16:48:33 -06:00
parent e185629d19
commit 0c2c0f653b
7 changed files with 18 additions and 7 deletions

View File

@@ -28,6 +28,20 @@ inline bool isPseudo(HANDLE h) noexcept { return reinterpret_cast<int32_t>(h) <
} // namespace
Handles::~Handles() { clear(); }
void Handles::clear() {
for (auto &entry : mSlots) {
if (entry.obj) {
detail::deref(entry.obj);
}
}
mSlots.clear();
mFreeBelow.clear();
mFreeAbove.clear();
nextIndex = 0;
}
HANDLE Handles::alloc(Pin<> obj, uint32_t grantedAccess, uint32_t flags) {
std::unique_lock lk(m);