Ensure cached pointer wrappers are cleaned up when deleted
This commit is contained in:
parent
95a2270ca3
commit
2c94f6ab50
|
@ -30,6 +30,12 @@ namespace PkmnLibSharp.Utilities
|
|||
Cached.TryAdd(ptr, weakRef);
|
||||
}
|
||||
|
||||
~PointerWrapper()
|
||||
{
|
||||
if (!_isDeleted)
|
||||
Cached.TryRemove(Ptr, out _);
|
||||
}
|
||||
|
||||
public static bool TryResolvePointer<T>(IntPtr p, out T result) where T : PointerWrapper
|
||||
{
|
||||
if (Cached.TryGetValue(p, out var val))
|
||||
|
|
Loading…
Reference in New Issue