Skip to content

Commit

Permalink
Copy the NativeAOT AllocateTypeAssociatedMemory to Mono
Browse files Browse the repository at this point in the history
Found in dotnet#99019
  • Loading branch information
MichalPetryka authored Feb 28, 2024
1 parent 7608b3a commit f408cb4
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,13 @@ public static void RunModuleConstructor(ModuleHandle module)

public static IntPtr AllocateTypeAssociatedMemory(Type type, int size)
{
throw new PlatformNotSupportedException();
if (type is not RuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(type));

ArgumentOutOfRangeException.ThrowIfNegative(size);

// We don't support unloading; the memory will never be freed.
return (IntPtr)NativeMemory.AllocZeroed((uint)size);
}

[Intrinsic]
Expand Down

0 comments on commit f408cb4

Please sign in to comment.