From 51b58e7a884701fe42d786d5d8870283e02fac9b Mon Sep 17 00:00:00 2001 From: gitee-bot Date: Tue, 3 Mar 2026 06:46:20 +0000 Subject: [PATCH] docs: add documentation comments for functions in PR #59604 --- src/backend/Assembly.zig | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/backend/Assembly.zig b/src/backend/Assembly.zig index 5a2afae..dab5719 100644 --- a/src/backend/Assembly.zig +++ b/src/backend/Assembly.zig @@ -2,20 +2,36 @@ const std = @import("std"); const Allocator = std.mem.Allocator; /// Assembly holds the data and text sections of compiled code. +/// +/// # Fields +/// * `data` - The data section containing initialized data +/// * `text` - The text section containing executable code data: []const u8, text: []const u8, const Assembly = @This(); +/// Frees the memory allocated for both the data and text sections. +/// +/// # Arguments +/// * `gpa` - The allocator used to free memory pub fn deinit(self: *const Assembly, gpa: Allocator) void { gpa.free(self.data); gpa.free(self.text); } -pub fn writeToFile(self: Assembly, file: std.fs.File) !void { +/// Writes both the data and text sections of the Assembly to a file. +/// Uses writevAll to efficiently write both sections in a single system call. +/// +/// # Arguments +/// * `file` - The file to write to +/// +/// # Errors +/// Returns an error 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 }, .{ .base = self.text.ptr, .len = self.text.len }, }; return file.writevAll(&vec); -} +} \ No newline at end of file -- Gitee