diff --git a/src/backend/Assembly.zig b/src/backend/Assembly.zig index 5a2afae9a79eb452cc99603cdd138335f7175be7..7eaf52352183dc16133f3ea0a0c054f328442683 100644 --- a/src/backend/Assembly.zig +++ b/src/backend/Assembly.zig @@ -7,11 +7,16 @@ text: []const u8, const Assembly = @This(); +/// Deallocates the memory used by the Assembly instance. +/// Frees both the data and text sections. pub fn deinit(self: *const Assembly, gpa: Allocator) void { gpa.free(self.data); gpa.free(self.text); } +/// Writes the Assembly data and text sections to a file. +/// Uses writev to efficiently write both sections in a single system call. +/// Returns an error if the write operation fails. pub fn writeToFile(self: Assembly, file: std.fs.File) !void { var vec: [2]std.posix.iovec_const = .{ .{ .base = self.data.ptr, .len = self.data.len },