diff --git a/src/BUTR.NativeAOT.Shared/Utils.cs b/src/BUTR.NativeAOT.Shared/Utils.cs index 3ec6cf0..f3d121b 100644 --- a/src/BUTR.NativeAOT.Shared/Utils.cs +++ b/src/BUTR.NativeAOT.Shared/Utils.cs @@ -67,6 +67,13 @@ public static string SerializeJson(TValue? value, JsonTypeInfo j } + private static unsafe SafeDataMallocHandle Copy(in ReadOnlySpan data, bool isOwner) + { + var dst = (byte*) Allocator.Alloc(new UIntPtr((uint) data.Length)); + data.CopyTo(new Span(dst, data.Length)); + return new(dst, data.Length, isOwner); + } + public static unsafe SafeStringMallocHandle Copy(in ReadOnlySpan str, bool isOwner) { var size = (uint) ((str.Length + 1) * 2);