Browse Source

Removed delegate handles list as that wasn't necessary for anything at all

console
Nico de Poel 5 years ago
parent
commit
14f7b78f1d
  1. 8
      Assets/Scripts/CallbackHandler.cs

8
Assets/Scripts/CallbackHandler.cs

@ -7,7 +7,6 @@ public abstract class CallbackHandler<THandler>
{ {
private GCHandle selfHandle; private GCHandle selfHandle;
private GCHandle callbacksHandle; private GCHandle callbacksHandle;
private List<GCHandle> delegateHandles = new List<GCHandle>();
public IntPtr ToIntPtr => callbacksHandle.AddrOfPinnedObject(); public IntPtr ToIntPtr => callbacksHandle.AddrOfPinnedObject();
@ -23,18 +22,11 @@ public abstract class CallbackHandler<THandler>
if (callbacksHandle.IsAllocated) if (callbacksHandle.IsAllocated)
callbacksHandle.Free(); callbacksHandle.Free();
foreach (var handle in delegateHandles)
{
if (handle.IsAllocated)
handle.Free();
}
selfHandle.Free(); selfHandle.Free();
} }
protected IntPtr CreateCallback<TDelegate>(TDelegate callback) protected IntPtr CreateCallback<TDelegate>(TDelegate callback)
{ {
delegateHandles.Add(GCHandle.Alloc(callback));
return Marshal.GetFunctionPointerForDelegate(callback); return Marshal.GetFunctionPointerForDelegate(callback);
} }

Loading…
Cancel
Save