protected override void Dispose(bool disposing) { if (disposing) { values = null; } MemoryHelpers.FreeMemory(nativeBuffer); nativeBuffer = IntPtr.Zero; }
/// <summary> /// Initializes a new instance of the <see cref="InterfaceArray"/> class. /// </summary> /// <param name="array">The array.</param> public unsafe InterfaceArray(params T[] array) { values = array; nativeBuffer = IntPtr.Zero; if (values != null) { var length = array.Length; values = new T[length]; nativeBuffer = MemoryHelpers.AllocateMemory(length * sizeof(IntPtr)); for (int i = 0; i < length; i++) { Set(i, array[i]); } } }
public InterfaceArray(params T[] array) { values = array; NativePointer = IntPtr.Zero; if (values != null) { var length = array.Length; values = new T[length]; NativePointer = MemoryHelpers.AllocateMemory(length * IntPtr.Size); for (int i = 0; i < length; i++) { this[i] = array[i]; } } }
private static unsafe int GetIids(IntPtr thisPtr, int *iidCount, IntPtr *iids) { try { InspectableShadow shadow = ToShadow <InspectableShadow>(thisPtr); IInspectable callback = (IInspectable)shadow.Callback; ShadowContainer container = callback.Shadow; int countGuids = container.Guids.Length; // Copy GUIDs deduced from Callback iids = (IntPtr *)Marshal.AllocCoTaskMem(IntPtr.Size * countGuids); *iidCount = countGuids; MemoryHelpers.CopyMemory((IntPtr)iids, new ReadOnlySpan <IntPtr>(container.Guids)); } catch (Exception exception) { return((int)Result.GetResultFromException(exception)); } return(Result.Ok.Code); }
/// <summary> /// Initializes a new instance of the <see cref="InterfaceArray"/> class. /// </summary> /// <param name="size">The size.</param> public unsafe InterfaceArray(int size) { values = new T[size]; nativeBuffer = MemoryHelpers.AllocateMemory(size * sizeof(IntPtr)); }
public InterfaceArray(int size) { values = new T[size]; NativePointer = MemoryHelpers.AllocateMemory(size * IntPtr.Size); }