2015-11-06 14:31:50 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Common
|
|
|
|
|
{
|
|
|
|
|
public class UnmanagedResourceHeap : IDisposable
|
|
|
|
|
{
|
|
|
|
|
public IntPtr StringToHGlobalAnsi(string str)
|
|
|
|
|
{
|
|
|
|
|
var ret = Marshal.StringToHGlobalAnsi(str);
|
|
|
|
|
HGlobals.Add(ret);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<IntPtr> HGlobals = new List<IntPtr>();
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
foreach (var h in HGlobals)
|
2017-04-13 18:57:58 +00:00
|
|
|
|
{
|
2015-11-06 14:31:50 +00:00
|
|
|
|
Marshal.FreeHGlobal(h);
|
2017-04-13 18:57:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-06 14:31:50 +00:00
|
|
|
|
HGlobals.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|