Skip to content

Instantly share code, notes, and snippets.

@toptensoftware
Created November 2, 2016 08:48
Show Gist options
  • Select an option

  • Save toptensoftware/781e1f957343d128561b396037ec11e0 to your computer and use it in GitHub Desktop.

Select an option

Save toptensoftware/781e1f957343d128561b396037ec11e0 to your computer and use it in GitHub Desktop.
public class HandleMap
{
// Map between environments
public IntPtr To32(ushort handle16)
public ushort To16(IntPtr handle32)
// Remove destroyed handles
public void Destroy32(IntPtr handle32);
public void Destroy16(ushort handle16);
// Check if a handle is known
public bool IsValid16(ushort handle16)
// The map
Dictionary<IntPtr, ushort> _map32to16 = new Dictionary<IntPtr, ushort>();
Dictionary<ushort, IntPtr> _map16to32 = new Dictionary<ushort, IntPtr>();
// Next unused handle
ushort _nextHandle = 32;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment