Skip to content

Commit

Permalink
Eliminate return value from appending to a binary file
Browse files Browse the repository at this point in the history
  • Loading branch information
nloum committed Nov 18, 2024
1 parent 94259ad commit c07961e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions CodegenBot/Imports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ public interface ICodegenBotImports
public class CodegenBotImports : ICodegenBotImports
{
[DllImport("extism", EntryPoint = "cgb_append_to_binary_file")]
public static extern ulong ExternAppend(ulong pathOffset, ulong bytesOffset);
public static extern void ExternAppend(ulong pathOffset, ulong bytesOffset);

public byte[] AppendToBinaryFile(string filePath, byte[] binary)
public void AppendToBinaryFile(string filePath, byte[] binary)
{
using var block = Pdk.Allocate(filePath);
using var binaryBlock = Pdk.Allocate(binary);
var ptr = ExternAppend(block.Offset, binaryBlock.Offset);
var bytes = MemoryBlock.Find(ptr).ReadBytes();
return bytes;
ExternAppend(block.Offset, binaryBlock.Offset);
}

[DllImport("extism", EntryPoint = "cgb_read_binary_file")]
Expand Down

0 comments on commit c07961e

Please sign in to comment.