public NativeStringImpl <T, TMemManager> Clone() { var clone = new NativeStringImpl <T, TMemManager>(Capacity, m_MemoryAllocator.Label); UnsafeUtility.MemCpy(clone.m_StringData->buffer, m_StringData->buffer, m_StringData->length * UnsafeUtility.SizeOf <T>()); clone.m_StringData->length = m_StringData->length; return(clone); }
unsafe NativeString(int capacity, Allocator i_label, int stackDepth) { #if ENABLE_UNITY_COLLECTIONS_CHECKS #if UNITY_2018_3_OR_NEWER var guardian = new NativeBufferSentinel(stackDepth, i_label); m_Safety = (i_label == Allocator.Temp) ? AtomicSafetyHandle.GetTempMemoryHandle() : AtomicSafetyHandle.Create(); #else var guardian = new NativeBufferSentinel(stackDepth); m_Safety = AtomicSafetyHandle.Create(); #endif m_Impl = new NativeStringImpl <int, DefaultMemoryManager, NativeBufferSentinel>(capacity, i_label, guardian); #else m_Impl = new NativeStringImpl <T, DefaultMemoryManager>(capacity, i_label); #endif }