예제 #1
0
        public NativeListImpl(int capacity, Allocator allocatorLabel)
#endif
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            this.sentinel = sentinel;
            m_ListData    = null;

            if (!UnsafeUtility.IsBlittable <T>())
            {
                this.sentinel.Dispose();
                throw new ArgumentException(string.Format("{0} used in NativeList<{0}> must be blittable", typeof(T)));
            }
#endif
            m_MemoryAllocator = default(TMemManager);
            m_ListData        = (NativeListData *)m_MemoryAllocator.Init(UnsafeUtility.SizeOf <NativeListData>(), UnsafeUtility.AlignOf <NativeListData>(), allocatorLabel);

            var elementSize = UnsafeUtility.SizeOf <T>();

            //@TODO: Find out why this is needed?
            capacity           = Math.Max(1, capacity);
            m_ListData->buffer = UnsafeUtility.Malloc(capacity * elementSize, UnsafeUtility.AlignOf <T>(), allocatorLabel);

            m_ListData->length   = 0;
            m_ListData->capacity = capacity;
        }
예제 #2
0
 public NativeListImpl(int capacity, Allocator allocatorLabel, TSentinel sentinel)