aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Tests.Unicorn
diff options
context:
space:
mode:
authormerry <git@mary.rs>2022-10-24 00:51:54 +0100
committerGitHub <noreply@github.com>2022-10-23 23:51:54 +0000
commiteafadf10c7d8fe51ca6af11aadef64f5f6bcf8e0 (patch)
tree69dda4e2017a65a28b2b47d20f5bf9ca15fe2e93 /Ryujinx.Tests.Unicorn
parent9b06ee7736993494c9b7f730f22283edf8e550b7 (diff)
Ryujinx.Tests.Unicorn: Implement IDisposable (#3794)
Dispose unicorn when done
Diffstat (limited to 'Ryujinx.Tests.Unicorn')
-rw-r--r--Ryujinx.Tests.Unicorn/UnicornAArch32.cs20
-rw-r--r--Ryujinx.Tests.Unicorn/UnicornAArch64.cs20
2 files changed, 36 insertions, 4 deletions
diff --git a/Ryujinx.Tests.Unicorn/UnicornAArch32.cs b/Ryujinx.Tests.Unicorn/UnicornAArch32.cs
index e1efb52f..e634e0d2 100644
--- a/Ryujinx.Tests.Unicorn/UnicornAArch32.cs
+++ b/Ryujinx.Tests.Unicorn/UnicornAArch32.cs
@@ -3,9 +3,10 @@ using System;
namespace Ryujinx.Tests.Unicorn
{
- public class UnicornAArch32
+ public class UnicornAArch32 : IDisposable
{
internal readonly IntPtr uc;
+ private bool _isDisposed = false;
public IndexedProperty<int, uint> R
{
@@ -107,7 +108,22 @@ namespace Ryujinx.Tests.Unicorn
~UnicornAArch32()
{
- Interface.Checked(Native.Interface.uc_close(uc));
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_isDisposed)
+ {
+ Interface.Checked(Native.Interface.uc_close(uc));
+ _isDisposed = true;
+ }
}
public void RunForCount(ulong count)
diff --git a/Ryujinx.Tests.Unicorn/UnicornAArch64.cs b/Ryujinx.Tests.Unicorn/UnicornAArch64.cs
index 4453d18d..c5d5540b 100644
--- a/Ryujinx.Tests.Unicorn/UnicornAArch64.cs
+++ b/Ryujinx.Tests.Unicorn/UnicornAArch64.cs
@@ -3,9 +3,10 @@ using System;
namespace Ryujinx.Tests.Unicorn
{
- public class UnicornAArch64
+ public class UnicornAArch64 : IDisposable
{
internal readonly IntPtr uc;
+ private bool _isDisposed = false;
public IndexedProperty<int, ulong> X
{
@@ -96,7 +97,22 @@ namespace Ryujinx.Tests.Unicorn
~UnicornAArch64()
{
- Interface.Checked(Native.Interface.uc_close(uc));
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_isDisposed)
+ {
+ Interface.Checked(Native.Interface.uc_close(uc));
+ _isDisposed = true;
+ }
}
public void RunForCount(ulong count)