Don't leak memory in the blip buff wrapper if something goes bad
This commit is contained in:
parent
3cedc7479f
commit
871c16028a
|
@ -74,7 +74,7 @@ namespace BizHawk.Emulation.Common
|
|||
public static extern void blip_delete(IntPtr context);
|
||||
}
|
||||
|
||||
IntPtr context;
|
||||
private IntPtr context;
|
||||
|
||||
public BlipBuffer(int sample_count)
|
||||
{
|
||||
|
@ -83,10 +83,19 @@ namespace BizHawk.Emulation.Common
|
|||
throw new Exception("blip_new returned NULL!");
|
||||
}
|
||||
|
||||
~BlipBuffer()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
BlipBufDll.blip_delete(context);
|
||||
context = IntPtr.Zero;
|
||||
if (context != IntPtr.Zero)
|
||||
{
|
||||
BlipBufDll.blip_delete(context);
|
||||
context = IntPtr.Zero;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetRates(double clock_rate, double sample_rate)
|
||||
|
|
Loading…
Reference in New Issue