Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NativeHeapMemoryBlock.cs
Go to the documentation of this file.
1
using
System.Runtime.InteropServices
;
2
using
System.Threading
;
3
4
namespace
System.Reflection.Internal
;
5
6
internal
sealed
class
NativeHeapMemoryBlock
:
AbstractMemoryBlock
7
{
8
private
sealed
class
DisposableData
:
CriticalDisposableObject
9
{
10
private
IntPtr
_pointer
;
11
12
public
unsafe
byte
*
Pointer
=> (
byte
*)(
void
*)
_pointer
;
13
14
public
DisposableData
(
int
size)
15
{
16
_pointer
=
Marshal
.
AllocHGlobal
(size);
17
}
18
19
protected
override
void
Release
()
20
{
21
IntPtr
intPtr =
Interlocked
.
Exchange
(ref
_pointer
,
IntPtr
.
Zero
);
22
if
(intPtr !=
IntPtr
.
Zero
)
23
{
24
Marshal
.
FreeHGlobal
(intPtr);
25
}
26
}
27
}
28
29
private
readonly
DisposableData
_data
;
30
31
private
readonly
int
_size
;
32
33
public
unsafe
override
byte
*
Pointer
=>
_data
.
Pointer
;
34
35
public
override
int
Size
=>
_size
;
36
37
internal
NativeHeapMemoryBlock
(
int
size)
38
{
39
_data
=
new
DisposableData
(size);
40
_size
= size;
41
}
42
43
public
override
void
Dispose
()
44
{
45
_data
.
Dispose
();
46
}
47
}
System.Reflection.Internal.AbstractMemoryBlock
Definition
AbstractMemoryBlock.cs:7
System.Reflection.Internal.CriticalDisposableObject.Dispose
void Dispose()
Definition
CriticalDisposableObject.cs:9
System.Reflection.Internal.CriticalDisposableObject
Definition
CriticalDisposableObject.cs:6
System.Reflection.Internal.NativeHeapMemoryBlock.DisposableData.Release
override void Release()
Definition
NativeHeapMemoryBlock.cs:19
System.Reflection.Internal.NativeHeapMemoryBlock.DisposableData.Pointer
unsafe byte * Pointer
Definition
NativeHeapMemoryBlock.cs:12
System.Reflection.Internal.NativeHeapMemoryBlock.DisposableData.DisposableData
DisposableData(int size)
Definition
NativeHeapMemoryBlock.cs:14
System.Reflection.Internal.NativeHeapMemoryBlock.DisposableData._pointer
IntPtr _pointer
Definition
NativeHeapMemoryBlock.cs:10
System.Reflection.Internal.NativeHeapMemoryBlock.DisposableData
Definition
NativeHeapMemoryBlock.cs:9
System.Reflection.Internal.NativeHeapMemoryBlock.Dispose
override void Dispose()
Definition
NativeHeapMemoryBlock.cs:43
System.Reflection.Internal.NativeHeapMemoryBlock._size
readonly int _size
Definition
NativeHeapMemoryBlock.cs:31
System.Reflection.Internal.NativeHeapMemoryBlock.NativeHeapMemoryBlock
NativeHeapMemoryBlock(int size)
Definition
NativeHeapMemoryBlock.cs:37
System.Reflection.Internal.NativeHeapMemoryBlock.Size
override int Size
Definition
NativeHeapMemoryBlock.cs:35
System.Reflection.Internal.NativeHeapMemoryBlock._data
readonly DisposableData _data
Definition
NativeHeapMemoryBlock.cs:29
System.Reflection.Internal.NativeHeapMemoryBlock
Definition
NativeHeapMemoryBlock.cs:7
System.Reflection.Pointer
Definition
Pointer.cs:8
System.Runtime.InteropServices.Marshal.FreeHGlobal
static void FreeHGlobal(IntPtr hglobal)
Definition
Marshal.cs:1680
System.Runtime.InteropServices.Marshal.AllocHGlobal
static IntPtr AllocHGlobal(int cb)
Definition
Marshal.cs:625
System.Runtime.InteropServices.Marshal
Definition
Marshal.cs:14
System.Threading.Interlocked.Exchange
static int Exchange(ref int location1, int value)
System.Threading.Interlocked
Definition
Interlocked.cs:9
System.Reflection.Internal
Definition
AbstractMemoryBlock.cs:4
System.Runtime.InteropServices
Definition
SequenceMarshal.cs:4
System.Threading
Definition
TaskToApm.cs:3
System.IntPtr.Zero
static readonly IntPtr Zero
Definition
IntPtr.cs:18
System.IntPtr
Definition
IntPtr.cs:14
source
System.Reflection.Metadata
System.Reflection.Internal
NativeHeapMemoryBlock.cs
Generated by
1.10.0