Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ AllocateUninitializedArray< T >()

static T[] System.GC.AllocateUninitializedArray< T > ( int length,
bool pinned = false )
inlinestatic

Definition at line 381 of file GC.cs.

382 {
383 if (!pinned)
384 {
385 if (RuntimeHelpers.IsReferenceOrContainsReferences<T>())
386 {
387 return new T[length];
388 }
389 if (length < 2048 / Unsafe.SizeOf<T>())
390 {
391 return new T[length];
392 }
393 }
394 else if (RuntimeHelpers.IsReferenceOrContainsReferences<T>())
395 {
396 ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T));
397 }
398 return AllocateNewUninitializedArray(length, pinned);
399 static T[] AllocateNewUninitializedArray(int length, bool pinned)
400 {
401 GC_ALLOC_FLAGS gC_ALLOC_FLAGS = GC_ALLOC_FLAGS.GC_ALLOC_ZEROING_OPTIONAL;
402 if (pinned)
403 {
404 gC_ALLOC_FLAGS |= GC_ALLOC_FLAGS.GC_ALLOC_PINNED_OBJECT_HEAP;
405 }
406 return Unsafe.As<T[]>(AllocateNewArray(typeof(T[]).TypeHandle.Value, length, gC_ALLOC_FLAGS));
407 }
408 }
static Array AllocateNewArray(IntPtr typeHandle, int length, GC_ALLOC_FLAGS flags)
GC_ALLOC_FLAGS
Definition GC.cs:10

References System.GC.AllocateNewArray(), System.length, and System.ThrowHelper.ThrowInvalidTypeWithPointersNotSupported().