Skip to content

Commit

Permalink
Removed a use of GetBytes in Instance.TryGetExtern and using a st…
Browse files Browse the repository at this point in the history
…ack buffer instead. (#287)
  • Loading branch information
martindevans authored Dec 1, 2023
1 parent 53133fa commit e03d3e1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Instance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,11 @@ public Instance(Store store, Module module, params object[] imports)

private bool TryGetExtern(StoreContext context, string name, out Extern ext)
{
using var nameBytes = name.ToUTF8(stackalloc byte[Math.Min(64, name.Length * 2)]);

unsafe
{
var nameBytes = Encoding.UTF8.GetBytes(name);
fixed (byte* ptr = nameBytes)
fixed (byte* ptr = nameBytes.Span)
{
return Native.wasmtime_instance_export_get(context.handle, this.instance, ptr, (UIntPtr)nameBytes.Length, out ext);
}
Expand Down

0 comments on commit e03d3e1

Please sign in to comment.