2013-11-22 09:33:56 +00:00
|
|
|
using System;
|
2017-03-10 14:22:45 +00:00
|
|
|
using System.Runtime.InteropServices;
|
2013-11-22 09:33:56 +00:00
|
|
|
|
|
|
|
namespace BizHawk.Common
|
|
|
|
{
|
|
|
|
public unsafe class SharedMemoryBlock : IDisposable
|
|
|
|
{
|
|
|
|
public string Name;
|
|
|
|
public string BlockName;
|
|
|
|
public int Size;
|
|
|
|
public byte* Ptr;
|
2017-03-10 14:22:45 +00:00
|
|
|
byte[] bytes;
|
|
|
|
GCHandle handle;
|
2013-11-22 09:33:56 +00:00
|
|
|
|
|
|
|
public void Allocate()
|
|
|
|
{
|
2017-03-10 14:22:45 +00:00
|
|
|
bytes = new byte[Size];
|
|
|
|
handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
|
|
|
Ptr = (byte*)handle.AddrOfPinnedObject();
|
2013-11-22 09:33:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
{
|
2017-03-10 14:22:45 +00:00
|
|
|
handle.Free();
|
|
|
|
bytes = null;
|
2013-11-22 09:33:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|