浏览代码

Be explicit about NSData creation

/3.1
Tim Mowrer 5 年前
当前提交
b8b9d84e
共有 1 个文件被更改,包括 15 次插入9 次删除
  1. 24
      Assets/Scripts/Multipeer/NSData.cs

24
Assets/Scripts/Multipeer/NSData.cs


public int Length => Created ? GetLength(this) : 0;
public unsafe NSData(NativeSlice<byte> bytes, bool copy)
public static unsafe NSData CreateWithBytes(NativeSlice<byte> bytes)
if (copy)
{
m_Ptr = CreateWithBytes(bytes.GetUnsafePtr(), bytes.Length);
}
else
{
m_Ptr = CreateWithBytesNoCopy(bytes.GetUnsafePtr(), bytes.Length, false);
}
var ptr = bytes.GetUnsafePtr();
if (ptr == null)
throw new ArgumentException($"The {typeof(NativeSlice<byte>).Name} is not valid.", nameof(bytes));
return new NSData(CreateWithBytes(ptr, bytes.Length));
}
public static unsafe NSData CreateWithBytesNoCopy(NativeSlice<byte> bytes)
{
var ptr = bytes.GetUnsafePtr();
if (ptr == null)
throw new ArgumentException($"The {typeof(NativeSlice<byte>).Name} is not valid.", nameof(bytes));
return new NSData(CreateWithBytesNoCopy(ptr, bytes.Length, false));
}
public unsafe NativeSlice<byte> Bytes

正在加载...
取消
保存