Skip to content

Commit ae30997

Browse files
authored
Merge pull request #2434 from terminal-cs/master
Implement System.Runtime.InteropServices.NativeMemory
2 parents 0733e56 + ea26685 commit ae30997

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using IL2CPU.API.Attribs;
2+
using Cosmos.Core.Memory;
3+
using Cosmos.Core;
4+
5+
namespace System.Runtime.InteropServices
6+
{
7+
[Plug("System.Runtime.InteropServices.NativeMemory, System.Private.CoreLib")]
8+
public static unsafe class NativeMemory
9+
{
10+
public static void* Realloc(void* ptr, nuint byteCount)
11+
{
12+
return Heap.Realloc((byte*)ptr, (uint)byteCount);
13+
}
14+
15+
public static void* Alloc(nuint elementCount, nuint elementSize)
16+
{
17+
return Heap.Alloc((uint)(elementCount * elementSize));
18+
}
19+
public static void* Alloc(nuint byteCount)
20+
{
21+
return Heap.Alloc((uint)byteCount);
22+
}
23+
24+
public static void Free(void* ptr)
25+
{
26+
Heap.Free(ptr);
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)