Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

updateConfiguration

WebServer.updateConfiguration
pub fn updateConfiguration(ws: *WebServer, maker: *Maker) !void

File

lib/compiler/Maker/WebServer.zig:141

Code

pub fn updateConfiguration(ws: *WebServer, maker: *Maker) !void {
    const graph = ws.graph;
    const gpa = maker.gpa;
    const all_steps = maker.step_stack.keys();
    const c = &maker.scanned_config.configuration;

    const step_names_trailing = try gpa.alloc(u8, len: {
        var name_bytes: usize = 0;
        for (all_steps) |step_index| name_bytes += step_index.ptr(c).name.slice(c).len;
        break :len name_bytes + all_steps.len * 4;
    });
    errdefer gpa.free(step_names_trailing);

    {
        const step_name_lens: []align(1) u32 = @ptrCast(step_names_trailing[0 .. all_steps.len * 4]);
        var idx: usize = all_steps.len * 4;
        for (all_steps, step_name_lens) |step_index, *name_len| {
            const step_name = step_index.ptr(c).name.slice(c);
            name_len.* = @intCast(step_name.len);
            @memcpy(step_names_trailing[idx..][0..step_name.len], step_name);
            idx += step_name.len;
        }
        assert(idx == step_names_trailing.len);
    }

    const step_status_bits = try gpa.alloc(u8, @divCeil(all_steps.len, 4));
    errdefer gpa.free(step_status_bits);
    @memset(step_status_bits, 0);

    const time_reports_len: usize = if (graph.time_report) all_steps.len else 0;
    const time_report_msgs = try gpa.alloc([]u8, time_reports_len);
    errdefer gpa.free(time_report_msgs);
    const time_report_update_times = try gpa.alloc(i64, time_reports_len);
    errdefer gpa.free(time_report_update_times);
    @memset(time_report_msgs, &.{});
    @memset(time_report_update_times, std.math.minInt(i64));

    ws.releaseConfigured();

    ws.configured = .{
        .maker = maker,
        .step_names_trailing = step_names_trailing,
        .step_status_bits = step_status_bits,
        .time_report_mutex = .init,
        .time_report_msgs = time_report_msgs,
        .time_report_update_times = time_report_update_times,
    };
}