Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement System.Runtime.InteropServices.NativeMemory #2434

Merged
merged 3 commits into from
Oct 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using IL2CPU.API.Attribs;
using Cosmos.Core.Memory;
using Cosmos.Core;

namespace System.Runtime.InteropServices
{
[Plug("System.Runtime.InteropServices.NativeMemory, System.Private.CoreLib")]
public static unsafe class NativeMemory
{
public static void* Realloc(void* ptr, nuint byteCount)
{
return Heap.Realloc((byte*)ptr, (uint)byteCount);
}

public static void* Alloc(nuint elementCount, nuint elementSize)
{
return Heap.Alloc((uint)(elementCount * elementSize));
}
public static void* Alloc(nuint byteCount)
{
return Heap.Alloc((uint)byteCount);
}

public static void Free(void* ptr)
{
Heap.Free(ptr);
}
}
}