diff --git a/src/backend/Assembly.zig b/src/backend/Assembly.zig index 914bffb033bfff5923a987cb6e997a23973c3155..1caa9e501b26aa56dec7e0d02a140f44c9284ed4 100644 --- a/src/backend/Assembly.zig +++ b/src/backend/Assembly.zig @@ -6,11 +6,18 @@ text: []const u8, const Assembly = @This(); +/// Frees the memory allocated for the assembly data and text sections. +/// This should be called when the Assembly instance is no longer needed. 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 using writev for efficiency. +/// This writes both sections sequentially without any separator between them. +/// +/// **Errors:** +/// - Returns any error from `file.writevAll` if the write operation fails. pub fn writeToAllFile(self: Assembly, file: std.fs.File) !void { var vec: [2]std.posix.iovec_const = .{ .{ .base = self.data.ptr, .len = self.data.len },