Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ByteArrayMemoryProvider.cs
Go to the documentation of this file.
2using System.IO;
4
6
8{
9 private readonly ImmutableArray<byte> _array;
10
12
13 public override int Size => _array.Length;
14
16
17 internal unsafe byte* Pointer
18 {
19 get
20 {
21 if (_pinned == null)
22 {
24 if (Interlocked.CompareExchange(ref _pinned, pinnedObject, null) != null)
25 {
26 pinnedObject.Dispose();
27 }
28 }
29 return _pinned.Pointer;
30 }
31 }
32
37
38 protected override void Dispose(bool disposing)
39 {
40 Interlocked.Exchange(ref _pinned, null)?.Dispose();
41 }
42
43 protected override AbstractMemoryBlock GetMemoryBlockImpl(int start, int size)
44 {
45 return new ByteArrayMemoryBlock(this, start, size);
46 }
47
48 public override Stream GetStream(out StreamConstraints constraints)
49 {
50 constraints = new StreamConstraints(null, 0L, Size);
51 return new ImmutableMemoryStream(_array);
52 }
53}
override AbstractMemoryBlock GetMemoryBlockImpl(int start, int size)
override Stream GetStream(out StreamConstraints constraints)
static ? byte[] DangerousGetUnderlyingArray(ImmutableArray< byte > array)
static int CompareExchange(ref int location1, int value, int comparand)
static int Exchange(ref int location1, int value)