Example #1
0
            static T[] AllocateNewUninitializedArray(int length, bool pinned)
            {
                GC_ALLOC_FLAGS flags = GC_ALLOC_FLAGS.GC_ALLOC_ZEROING_OPTIONAL;

                if (pinned)
                {
                    flags |= GC_ALLOC_FLAGS.GC_ALLOC_PINNED_OBJECT_HEAP;
                }

                if (length < 0)
                {
                    throw new OverflowException();
                }

                T[] array = null;
                RuntimeImports.RhAllocateNewArray(EETypePtr.EETypePtrOf <T[]>().RawValue, (uint)length, (uint)flags, Unsafe.AsPointer(ref array));
                if (array == null)
                {
                    throw new OutOfMemoryException();
                }

                return(array);
            }