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);
|
public static extern void blip_delete(IntPtr context);
|
||||||
}
|
}
|
||||||
|
|
||||||
IntPtr context;
|
private IntPtr context;
|
||||||
|
|
||||||
public BlipBuffer(int sample_count)
|
public BlipBuffer(int sample_count)
|
||||||
{
|
{
|
||||||
|
@ -83,10 +83,19 @@ namespace BizHawk.Emulation.Common
|
||||||
throw new Exception("blip_new returned NULL!");
|
throw new Exception("blip_new returned NULL!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~BlipBuffer()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
BlipBufDll.blip_delete(context);
|
if (context != IntPtr.Zero)
|
||||||
context = IntPtr.Zero;
|
{
|
||||||
|
BlipBufDll.blip_delete(context);
|
||||||
|
context = IntPtr.Zero;
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRates(double clock_rate, double sample_rate)
|
public void SetRates(double clock_rate, double sample_rate)
|
||||||
|
|
Loading…
Reference in New Issue