public unsafe CFDataBuffer(byte[] buffer) { this.buffer = buffer; /* * Copy the buffer to allow the native side to take ownership. */ fixed(byte *ptr = buffer) data = CFData.FromData((IntPtr)ptr, buffer.Length); }
public CFDataBuffer(byte[] buffer) { this.buffer = buffer; /* * Copy the buffer to allow the native side to take ownership. */ var gch = GCHandle.Alloc(buffer, GCHandleType.Pinned); data = CFData.FromData(gch.AddrOfPinnedObject(), buffer.Length); gch.Free(); }