std.ArrayList: make unmanaged the default

This commit is contained in:
Andrew Kelley 2025-07-31 21:54:07 -07:00
parent d625158354
commit 749f10af49
161 changed files with 861 additions and 870 deletions

View File

@ -3,7 +3,6 @@ const builtin = std.builtin;
const tests = @import("test/tests.zig"); const tests = @import("test/tests.zig");
const BufMap = std.BufMap; const BufMap = std.BufMap;
const mem = std.mem; const mem = std.mem;
const ArrayList = std.ArrayList;
const io = std.io; const io = std.io;
const fs = std.fs; const fs = std.fs;
const InstallDirectoryOptions = std.Build.InstallDirectoryOptions; const InstallDirectoryOptions = std.Build.InstallDirectoryOptions;
@ -925,7 +924,7 @@ fn addCxxKnownPath(
return error.RequiredLibraryNotFound; return error.RequiredLibraryNotFound;
const path_padded = run: { const path_padded = run: {
var args = std.ArrayList([]const u8).init(b.allocator); var args = std.array_list.Managed([]const u8).init(b.allocator);
try args.append(ctx.cxx_compiler); try args.append(ctx.cxx_compiler);
var it = std.mem.tokenizeAny(u8, ctx.cxx_compiler_arg1, &std.ascii.whitespace); var it = std.mem.tokenizeAny(u8, ctx.cxx_compiler_arg1, &std.ascii.whitespace);
while (it.next()) |arg| try args.append(arg); while (it.next()) |arg| try args.append(arg);

View File

@ -6241,9 +6241,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
C has a default allocator - <code>malloc</code>, <code>realloc</code>, and <code>free</code>. C has a default allocator - <code>malloc</code>, <code>realloc</code>, and <code>free</code>.
When linking against libc, Zig exposes this allocator with {#syntax#}std.heap.c_allocator{#endsyntax#}. When linking against libc, Zig exposes this allocator with {#syntax#}std.heap.c_allocator{#endsyntax#}.
However, by convention, there is no default allocator in Zig. Instead, functions which need to However, by convention, there is no default allocator in Zig. Instead, functions which need to
allocate accept an {#syntax#}Allocator{#endsyntax#} parameter. Likewise, data structures such as allocate accept an {#syntax#}Allocator{#endsyntax#} parameter. Likewise, some data structures
{#syntax#}std.ArrayList{#endsyntax#} accept an {#syntax#}Allocator{#endsyntax#} parameter in accept an {#syntax#}Allocator{#endsyntax#} parameter in their initialization functions:
their initialization functions:
</p> </p>
{#code|test_allocator.zig#} {#code|test_allocator.zig#}

View File

@ -1,7 +1,7 @@
const std = @import("std"); const std = @import("std");
test "detect leak" { test "detect leak" {
var list = std.ArrayList(u21).init(std.testing.allocator); var list = std.array_list.Managed(u21).init(std.testing.allocator);
// missing `defer list.deinit();` // missing `defer list.deinit();`
try list.append('☔'); try list.append('☔');

View File

@ -533,7 +533,7 @@ fn generateSystemDefines(comp: *Compilation, w: anytype) !void {
pub fn generateBuiltinMacros(comp: *Compilation, system_defines_mode: SystemDefinesMode) !Source { pub fn generateBuiltinMacros(comp: *Compilation, system_defines_mode: SystemDefinesMode) !Source {
try comp.generateBuiltinTypes(); try comp.generateBuiltinTypes();
var buf = std.ArrayList(u8).init(comp.gpa); var buf = std.array_list.Managed(u8).init(comp.gpa);
defer buf.deinit(); defer buf.deinit();
if (system_defines_mode == .include_system_defines) { if (system_defines_mode == .include_system_defines) {
@ -1143,7 +1143,7 @@ pub fn addSourceFromOwnedBuffer(comp: *Compilation, buf: []u8, path: []const u8,
const duped_path = try comp.gpa.dupe(u8, path); const duped_path = try comp.gpa.dupe(u8, path);
errdefer comp.gpa.free(duped_path); errdefer comp.gpa.free(duped_path);
var splice_list = std.ArrayList(u32).init(comp.gpa); var splice_list = std.array_list.Managed(u32).init(comp.gpa);
defer splice_list.deinit(); defer splice_list.deinit();
const source_id: Source.Id = @enumFromInt(comp.sources.count() + 2); const source_id: Source.Id = @enumFromInt(comp.sources.count() + 2);
@ -1428,7 +1428,7 @@ fn getFileContents(comp: *Compilation, path: []const u8, limit: ?u32) ![]const u
const file = try comp.cwd.openFile(path, .{}); const file = try comp.cwd.openFile(path, .{});
defer file.close(); defer file.close();
var buf = std.ArrayList(u8).init(comp.gpa); var buf = std.array_list.Managed(u8).init(comp.gpa);
defer buf.deinit(); defer buf.deinit();
const max = limit orelse std.math.maxInt(u32); const max = limit orelse std.math.maxInt(u32);

View File

@ -590,7 +590,7 @@ var stdout_buffer: [4096]u8 = undefined;
/// The entry point of the Aro compiler. /// The entry point of the Aro compiler.
/// **MAY call `exit` if `fast_exit` is set.** /// **MAY call `exit` if `fast_exit` is set.**
pub fn main(d: *Driver, tc: *Toolchain, args: []const []const u8, comptime fast_exit: bool) !void { pub fn main(d: *Driver, tc: *Toolchain, args: []const []const u8, comptime fast_exit: bool) !void {
var macro_buf = std.ArrayList(u8).init(d.comp.gpa); var macro_buf = std.array_list.Managed(u8).init(d.comp.gpa);
defer macro_buf.deinit(); defer macro_buf.deinit();
const std_out = std.fs.File.stdout().deprecatedWriter(); const std_out = std.fs.File.stdout().deprecatedWriter();
@ -817,7 +817,7 @@ fn dumpLinkerArgs(items: []const []const u8) !void {
/// The entry point of the Aro compiler. /// The entry point of the Aro compiler.
/// **MAY call `exit` if `fast_exit` is set.** /// **MAY call `exit` if `fast_exit` is set.**
pub fn invokeLinker(d: *Driver, tc: *Toolchain, comptime fast_exit: bool) !void { pub fn invokeLinker(d: *Driver, tc: *Toolchain, comptime fast_exit: bool) !void {
var argv = std.ArrayList([]const u8).init(d.comp.gpa); var argv = std.array_list.Managed([]const u8).init(d.comp.gpa);
defer argv.deinit(); defer argv.deinit();
var linker_path_buf: [std.fs.max_path_bytes]u8 = undefined; var linker_path_buf: [std.fs.max_path_bytes]u8 = undefined;

View File

@ -9,7 +9,7 @@ const TokenIndex = Tree.TokenIndex;
const NodeIndex = Tree.NodeIndex; const NodeIndex = Tree.NodeIndex;
const Type = @import("Type.zig"); const Type = @import("Type.zig");
const Diagnostics = @import("Diagnostics.zig"); const Diagnostics = @import("Diagnostics.zig");
const NodeList = std.ArrayList(NodeIndex); const NodeList = std.array_list.Managed(NodeIndex);
const Parser = @import("Parser.zig"); const Parser = @import("Parser.zig");
const Item = struct { const Item = struct {

View File

@ -15,7 +15,7 @@ const TokenIndex = Tree.TokenIndex;
const NodeIndex = Tree.NodeIndex; const NodeIndex = Tree.NodeIndex;
const Type = @import("Type.zig"); const Type = @import("Type.zig");
const Diagnostics = @import("Diagnostics.zig"); const Diagnostics = @import("Diagnostics.zig");
const NodeList = std.ArrayList(NodeIndex); const NodeList = std.array_list.Managed(NodeIndex);
const InitList = @import("InitList.zig"); const InitList = @import("InitList.zig");
const Attribute = @import("Attribute.zig"); const Attribute = @import("Attribute.zig");
const char_info = @import("char_info.zig"); const char_info = @import("char_info.zig");
@ -33,7 +33,7 @@ const target_util = @import("target.zig");
const Switch = struct { const Switch = struct {
default: ?TokenIndex = null, default: ?TokenIndex = null,
ranges: std.ArrayList(Range), ranges: std.array_list.Managed(Range),
ty: Type, ty: Type,
comp: *Compilation, comp: *Compilation,
@ -101,16 +101,16 @@ value_map: Tree.ValueMap,
// buffers used during compilation // buffers used during compilation
syms: SymbolStack = .{}, syms: SymbolStack = .{},
strings: std.ArrayListAligned(u8, .@"4"), strings: std.array_list.AlignedManaged(u8, .@"4"),
labels: std.ArrayList(Label), labels: std.array_list.Managed(Label),
list_buf: NodeList, list_buf: NodeList,
decl_buf: NodeList, decl_buf: NodeList,
param_buf: std.ArrayList(Type.Func.Param), param_buf: std.array_list.Managed(Type.Func.Param),
enum_buf: std.ArrayList(Type.Enum.Field), enum_buf: std.array_list.Managed(Type.Enum.Field),
record_buf: std.ArrayList(Type.Record.Field), record_buf: std.array_list.Managed(Type.Record.Field),
attr_buf: std.MultiArrayList(TentativeAttribute) = .{}, attr_buf: std.MultiArrayList(TentativeAttribute) = .{},
attr_application_buf: std.ArrayListUnmanaged(Attribute) = .empty, attr_application_buf: std.ArrayListUnmanaged(Attribute) = .empty,
field_attr_buf: std.ArrayList([]const Attribute), field_attr_buf: std.array_list.Managed([]const Attribute),
/// type name -> variable name location for tentative definitions (top-level defs with thus-far-incomplete types) /// type name -> variable name location for tentative definitions (top-level defs with thus-far-incomplete types)
/// e.g. `struct Foo bar;` where `struct Foo` is not defined yet. /// e.g. `struct Foo bar;` where `struct Foo` is not defined yet.
/// The key is the StringId of `Foo` and the value is the TokenIndex of `bar` /// The key is the StringId of `Foo` and the value is the TokenIndex of `bar`
@ -693,16 +693,16 @@ pub fn parse(pp: *Preprocessor) Compilation.Error!Tree {
.gpa = pp.comp.gpa, .gpa = pp.comp.gpa,
.arena = arena.allocator(), .arena = arena.allocator(),
.tok_ids = pp.tokens.items(.id), .tok_ids = pp.tokens.items(.id),
.strings = std.ArrayListAligned(u8, .@"4").init(pp.comp.gpa), .strings = std.array_list.AlignedManaged(u8, .@"4").init(pp.comp.gpa),
.value_map = Tree.ValueMap.init(pp.comp.gpa), .value_map = Tree.ValueMap.init(pp.comp.gpa),
.data = NodeList.init(pp.comp.gpa), .data = NodeList.init(pp.comp.gpa),
.labels = std.ArrayList(Label).init(pp.comp.gpa), .labels = std.array_list.Managed(Label).init(pp.comp.gpa),
.list_buf = NodeList.init(pp.comp.gpa), .list_buf = NodeList.init(pp.comp.gpa),
.decl_buf = NodeList.init(pp.comp.gpa), .decl_buf = NodeList.init(pp.comp.gpa),
.param_buf = std.ArrayList(Type.Func.Param).init(pp.comp.gpa), .param_buf = std.array_list.Managed(Type.Func.Param).init(pp.comp.gpa),
.enum_buf = std.ArrayList(Type.Enum.Field).init(pp.comp.gpa), .enum_buf = std.array_list.Managed(Type.Enum.Field).init(pp.comp.gpa),
.record_buf = std.ArrayList(Type.Record.Field).init(pp.comp.gpa), .record_buf = std.array_list.Managed(Type.Record.Field).init(pp.comp.gpa),
.field_attr_buf = std.ArrayList([]const Attribute).init(pp.comp.gpa), .field_attr_buf = std.array_list.Managed([]const Attribute).init(pp.comp.gpa),
.string_ids = .{ .string_ids = .{
.declspec_id = try StrInt.intern(pp.comp, "__declspec"), .declspec_id = try StrInt.intern(pp.comp, "__declspec"),
.main_id = try StrInt.intern(pp.comp, "main"), .main_id = try StrInt.intern(pp.comp, "main"),
@ -1222,7 +1222,7 @@ fn staticAssertMessage(p: *Parser, cond_node: NodeIndex, message: Result) !?[]co
const cond_tag = p.nodes.items(.tag)[@intFromEnum(cond_node)]; const cond_tag = p.nodes.items(.tag)[@intFromEnum(cond_node)];
if (cond_tag != .builtin_types_compatible_p and message.node == .none) return null; if (cond_tag != .builtin_types_compatible_p and message.node == .none) return null;
var buf = std.ArrayList(u8).init(p.gpa); var buf = std.array_list.Managed(u8).init(p.gpa);
defer buf.deinit(); defer buf.deinit();
if (cond_tag == .builtin_types_compatible_p) { if (cond_tag == .builtin_types_compatible_p) {
@ -3994,7 +3994,7 @@ fn msvcAsmStmt(p: *Parser) Error!?NodeIndex {
} }
/// asmOperand : ('[' IDENTIFIER ']')? asmStr '(' expr ')' /// asmOperand : ('[' IDENTIFIER ']')? asmStr '(' expr ')'
fn asmOperand(p: *Parser, names: *std.ArrayList(?TokenIndex), constraints: *NodeList, exprs: *NodeList) Error!void { fn asmOperand(p: *Parser, names: *std.array_list.Managed(?TokenIndex), constraints: *NodeList, exprs: *NodeList) Error!void {
if (p.eatToken(.l_bracket)) |l_bracket| { if (p.eatToken(.l_bracket)) |l_bracket| {
const ident = (try p.eatIdentifier()) orelse { const ident = (try p.eatIdentifier()) orelse {
try p.err(.expected_identifier); try p.err(.expected_identifier);
@ -4044,7 +4044,7 @@ fn gnuAsmStmt(p: *Parser, quals: Tree.GNUAssemblyQualifiers, asm_tok: TokenIndex
const allocator = stack_fallback.get(); const allocator = stack_fallback.get();
// TODO: Consider using a TokenIndex of 0 instead of null if we need to store the names in the tree // TODO: Consider using a TokenIndex of 0 instead of null if we need to store the names in the tree
var names = std.ArrayList(?TokenIndex).initCapacity(allocator, expected_items) catch unreachable; // stack allocation already succeeded var names = std.array_list.Managed(?TokenIndex).initCapacity(allocator, expected_items) catch unreachable; // stack allocation already succeeded
defer names.deinit(); defer names.deinit();
var constraints = NodeList.initCapacity(allocator, expected_items) catch unreachable; // stack allocation already succeeded var constraints = NodeList.initCapacity(allocator, expected_items) catch unreachable; // stack allocation already succeeded
defer constraints.deinit(); defer constraints.deinit();
@ -4317,7 +4317,7 @@ fn stmt(p: *Parser) Error!NodeIndex {
const old_switch = p.@"switch"; const old_switch = p.@"switch";
var @"switch" = Switch{ var @"switch" = Switch{
.ranges = std.ArrayList(Switch.Range).init(p.gpa), .ranges = std.array_list.Managed(Switch.Range).init(p.gpa),
.ty = cond.ty, .ty = cond.ty,
.comp = p.comp, .comp = p.comp,
}; };
@ -8268,7 +8268,7 @@ fn charLiteral(p: *Parser) Error!Result {
const max_chars_expected = 4; const max_chars_expected = 4;
var stack_fallback = std.heap.stackFallback(max_chars_expected * @sizeOf(u32), p.comp.gpa); var stack_fallback = std.heap.stackFallback(max_chars_expected * @sizeOf(u32), p.comp.gpa);
var chars = std.ArrayList(u32).initCapacity(stack_fallback.get(), max_chars_expected) catch unreachable; // stack allocation already succeeded var chars = std.array_list.Managed(u32).initCapacity(stack_fallback.get(), max_chars_expected) catch unreachable; // stack allocation already succeeded
defer chars.deinit(); defer chars.deinit();
while (char_literal_parser.next()) |item| switch (item) { while (char_literal_parser.next()) |item| switch (item) {

View File

@ -17,7 +17,7 @@ const features = @import("features.zig");
const Hideset = @import("Hideset.zig"); const Hideset = @import("Hideset.zig");
const DefineMap = std.StringHashMapUnmanaged(Macro); const DefineMap = std.StringHashMapUnmanaged(Macro);
const RawTokenList = std.ArrayList(RawToken); const RawTokenList = std.array_list.Managed(RawToken);
const max_include_depth = 200; const max_include_depth = 200;
/// Errors that can be returned when expanding a macro. /// Errors that can be returned when expanding a macro.
@ -84,7 +84,7 @@ tokens: Token.List = .{},
/// Do not directly mutate this; must be kept in sync with `tokens` /// Do not directly mutate this; must be kept in sync with `tokens`
expansion_entries: std.MultiArrayList(ExpansionEntry) = .{}, expansion_entries: std.MultiArrayList(ExpansionEntry) = .{},
token_buf: RawTokenList, token_buf: RawTokenList,
char_buf: std.ArrayList(u8), char_buf: std.array_list.Managed(u8),
/// Counter that is incremented each time preprocess() is called /// Counter that is incremented each time preprocess() is called
/// Can be used to distinguish multiple preprocessings of the same file /// Can be used to distinguish multiple preprocessings of the same file
preprocess_count: u32 = 0, preprocess_count: u32 = 0,
@ -131,7 +131,7 @@ pub fn init(comp: *Compilation) Preprocessor {
.gpa = comp.gpa, .gpa = comp.gpa,
.arena = std.heap.ArenaAllocator.init(comp.gpa), .arena = std.heap.ArenaAllocator.init(comp.gpa),
.token_buf = RawTokenList.init(comp.gpa), .token_buf = RawTokenList.init(comp.gpa),
.char_buf = std.ArrayList(u8).init(comp.gpa), .char_buf = std.array_list.Managed(u8).init(comp.gpa),
.poisoned_identifiers = std.StringHashMap(void).init(comp.gpa), .poisoned_identifiers = std.StringHashMap(void).init(comp.gpa),
.top_expansion_buf = ExpandBuf.init(comp.gpa), .top_expansion_buf = ExpandBuf.init(comp.gpa),
.hideset = .{ .comp = comp }, .hideset = .{ .comp = comp },
@ -982,7 +982,7 @@ fn expr(pp: *Preprocessor, tokenizer: *Tokenizer) MacroError!bool {
.tok_i = @intCast(token_state.tokens_len), .tok_i = @intCast(token_state.tokens_len),
.arena = pp.arena.allocator(), .arena = pp.arena.allocator(),
.in_macro = true, .in_macro = true,
.strings = std.ArrayListAligned(u8, .@"4").init(pp.comp.gpa), .strings = std.array_list.AlignedManaged(u8, .@"4").init(pp.comp.gpa),
.data = undefined, .data = undefined,
.value_map = undefined, .value_map = undefined,
@ -1140,7 +1140,7 @@ fn skipToNl(tokenizer: *Tokenizer) void {
} }
} }
const ExpandBuf = std.ArrayList(TokenWithExpansionLocs); const ExpandBuf = std.array_list.Managed(TokenWithExpansionLocs);
fn removePlacemarkers(buf: *ExpandBuf) void { fn removePlacemarkers(buf: *ExpandBuf) void {
var i: usize = buf.items.len -% 1; var i: usize = buf.items.len -% 1;
while (i < buf.items.len) : (i -%= 1) { while (i < buf.items.len) : (i -%= 1) {
@ -1151,7 +1151,7 @@ fn removePlacemarkers(buf: *ExpandBuf) void {
} }
} }
const MacroArguments = std.ArrayList([]const TokenWithExpansionLocs); const MacroArguments = std.array_list.Managed([]const TokenWithExpansionLocs);
fn deinitMacroArguments(allocator: Allocator, args: *const MacroArguments) void { fn deinitMacroArguments(allocator: Allocator, args: *const MacroArguments) void {
for (args.items) |item| { for (args.items) |item| {
for (item) |tok| TokenWithExpansionLocs.free(tok.expansion_locs, allocator); for (item) |tok| TokenWithExpansionLocs.free(tok.expansion_locs, allocator);
@ -2075,7 +2075,7 @@ fn collectMacroFuncArguments(
var parens: u32 = 0; var parens: u32 = 0;
var args = MacroArguments.init(pp.gpa); var args = MacroArguments.init(pp.gpa);
errdefer deinitMacroArguments(pp.gpa, &args); errdefer deinitMacroArguments(pp.gpa, &args);
var curArgument = std.ArrayList(TokenWithExpansionLocs).init(pp.gpa); var curArgument = std.array_list.Managed(TokenWithExpansionLocs).init(pp.gpa);
defer curArgument.deinit(); defer curArgument.deinit();
while (true) { while (true) {
var tok = try nextBufToken(pp, tokenizer, buf, start_idx, end_idx, extend_buf); var tok = try nextBufToken(pp, tokenizer, buf, start_idx, end_idx, extend_buf);
@ -2645,7 +2645,7 @@ fn define(pp: *Preprocessor, tokenizer: *Tokenizer, define_tok: RawToken) Error!
/// Handle a function like #define directive. /// Handle a function like #define directive.
fn defineFn(pp: *Preprocessor, tokenizer: *Tokenizer, define_tok: RawToken, macro_name: RawToken, l_paren: RawToken) Error!void { fn defineFn(pp: *Preprocessor, tokenizer: *Tokenizer, define_tok: RawToken, macro_name: RawToken, l_paren: RawToken) Error!void {
assert(macro_name.id.isMacroIdentifier()); assert(macro_name.id.isMacroIdentifier());
var params = std.ArrayList([]const u8).init(pp.gpa); var params = std.array_list.Managed([]const u8).init(pp.gpa);
defer params.deinit(); defer params.deinit();
// Parse the parameter list. // Parse the parameter list.
@ -3471,7 +3471,7 @@ test "Preserve pragma tokens sometimes" {
const allocator = std.testing.allocator; const allocator = std.testing.allocator;
const Test = struct { const Test = struct {
fn runPreprocessor(source_text: []const u8) ![]const u8 { fn runPreprocessor(source_text: []const u8) ![]const u8 {
var buf = std.ArrayList(u8).init(allocator); var buf = std.array_list.Managed(u8).init(allocator);
defer buf.deinit(); defer buf.deinit();
var comp = Compilation.init(allocator, std.fs.cwd()); var comp = Compilation.init(allocator, std.fs.cwd());
@ -3602,7 +3602,7 @@ test "Include guards" {
_ = try comp.addSourceFromBuffer(path, "int bar = 5;\n"); _ = try comp.addSourceFromBuffer(path, "int bar = 5;\n");
var buf = std.ArrayList(u8).init(allocator); var buf = std.array_list.Managed(u8).init(allocator);
defer buf.deinit(); defer buf.deinit();
var writer = buf.writer(); var writer = buf.writer();

View File

@ -157,7 +157,7 @@ pub fn getLinkerPath(tc: *const Toolchain, buf: []u8) ![]const u8 {
return use_linker; return use_linker;
} }
} else { } else {
var linker_name = try std.ArrayList(u8).initCapacity(tc.driver.comp.gpa, 5 + use_linker.len); // "ld64." ++ use_linker var linker_name = try std.array_list.Managed(u8).initCapacity(tc.driver.comp.gpa, 5 + use_linker.len); // "ld64." ++ use_linker
defer linker_name.deinit(); defer linker_name.deinit();
if (tc.getTarget().os.tag.isDarwin()) { if (tc.getTarget().os.tag.isDarwin()) {
linker_name.appendSliceAssumeCapacity("ld64."); linker_name.appendSliceAssumeCapacity("ld64.");
@ -198,7 +198,7 @@ fn possibleProgramNames(raw_triple: ?[]const u8, name: []const u8, buf: *[64]u8)
} }
/// Add toolchain `file_paths` to argv as `-L` arguments /// Add toolchain `file_paths` to argv as `-L` arguments
pub fn addFilePathLibArgs(tc: *const Toolchain, argv: *std.ArrayList([]const u8)) !void { pub fn addFilePathLibArgs(tc: *const Toolchain, argv: *std.array_list.Managed([]const u8)) !void {
try argv.ensureUnusedCapacity(tc.file_paths.items.len); try argv.ensureUnusedCapacity(tc.file_paths.items.len);
var bytes_needed: usize = 0; var bytes_needed: usize = 0;
@ -332,7 +332,7 @@ pub fn addPathFromComponents(tc: *Toolchain, components: []const []const u8, des
/// Add linker args to `argv`. Does not add path to linker executable as first item; that must be handled separately /// Add linker args to `argv`. Does not add path to linker executable as first item; that must be handled separately
/// Items added to `argv` will be string literals or owned by `tc.arena` so they must not be individually freed /// Items added to `argv` will be string literals or owned by `tc.arena` so they must not be individually freed
pub fn buildLinkerArgs(tc: *Toolchain, argv: *std.ArrayList([]const u8)) !void { pub fn buildLinkerArgs(tc: *Toolchain, argv: *std.array_list.Managed([]const u8)) !void {
return switch (tc.inner) { return switch (tc.inner) {
.uninitialized => unreachable, .uninitialized => unreachable,
.linux => |*linux| linux.buildLinkerArgs(tc, argv), .linux => |*linux| linux.buildLinkerArgs(tc, argv),
@ -412,7 +412,7 @@ fn getAsNeededOption(is_solaris: bool, needed: bool) []const u8 {
} }
} }
fn addUnwindLibrary(tc: *const Toolchain, argv: *std.ArrayList([]const u8)) !void { fn addUnwindLibrary(tc: *const Toolchain, argv: *std.array_list.Managed([]const u8)) !void {
const unw = try tc.getUnwindLibKind(); const unw = try tc.getUnwindLibKind();
const target = tc.getTarget(); const target = tc.getTarget();
if ((target.abi.isAndroid() and unw == .libgcc) or if ((target.abi.isAndroid() and unw == .libgcc) or
@ -450,7 +450,7 @@ fn addUnwindLibrary(tc: *const Toolchain, argv: *std.ArrayList([]const u8)) !voi
} }
} }
fn addLibGCC(tc: *const Toolchain, argv: *std.ArrayList([]const u8)) !void { fn addLibGCC(tc: *const Toolchain, argv: *std.array_list.Managed([]const u8)) !void {
const libgcc_kind = tc.getLibGCCKind(); const libgcc_kind = tc.getLibGCCKind();
if (libgcc_kind == .static or libgcc_kind == .unspecified) { if (libgcc_kind == .static or libgcc_kind == .unspecified) {
try argv.append("-lgcc"); try argv.append("-lgcc");
@ -461,7 +461,7 @@ fn addLibGCC(tc: *const Toolchain, argv: *std.ArrayList([]const u8)) !void {
} }
} }
pub fn addRuntimeLibs(tc: *const Toolchain, argv: *std.ArrayList([]const u8)) !void { pub fn addRuntimeLibs(tc: *const Toolchain, argv: *std.array_list.Managed([]const u8)) !void {
const target = tc.getTarget(); const target = tc.getTarget();
const rlt = tc.getRuntimeLibKind(); const rlt = tc.getRuntimeLibKind();
switch (rlt) { switch (rlt) {

View File

@ -41,7 +41,7 @@ pub const TokenWithExpansionLocs = struct {
pub fn addExpansionLocation(tok: *TokenWithExpansionLocs, gpa: std.mem.Allocator, new: []const Source.Location) !void { pub fn addExpansionLocation(tok: *TokenWithExpansionLocs, gpa: std.mem.Allocator, new: []const Source.Location) !void {
if (new.len == 0 or tok.id == .whitespace or tok.id == .macro_ws or tok.id == .placemarker) return; if (new.len == 0 or tok.id == .whitespace or tok.id == .macro_ws or tok.id == .placemarker) return;
var list = std.ArrayList(Source.Location).init(gpa); var list = std.array_list.Managed(Source.Location).init(gpa);
defer { defer {
@memset(list.items.ptr[list.items.len..list.capacity], .{}); @memset(list.items.ptr[list.items.len..list.capacity], .{});
// Add a sentinel to indicate the end of the list since // Add a sentinel to indicate the end of the list since

View File

@ -162,7 +162,7 @@ pub fn getDefaultLinker(self: *const Linux, target: std.Target) []const u8 {
return "ld"; return "ld";
} }
pub fn buildLinkerArgs(self: *const Linux, tc: *const Toolchain, argv: *std.ArrayList([]const u8)) Compilation.Error!void { pub fn buildLinkerArgs(self: *const Linux, tc: *const Toolchain, argv: *std.array_list.Managed([]const u8)) Compilation.Error!void {
const d = tc.driver; const d = tc.driver;
const target = tc.getTarget(); const target = tc.getTarget();
@ -465,7 +465,7 @@ test Linux {
try toolchain.discover(); try toolchain.discover();
var argv = std.ArrayList([]const u8).init(driver.comp.gpa); var argv = std.array_list.Managed([]const u8).init(driver.comp.gpa);
defer argv.deinit(); defer argv.deinit();
var linker_path_buf: [std.fs.max_path_bytes]u8 = undefined; var linker_path_buf: [std.fs.max_path_bytes]u8 = undefined;

View File

@ -30,7 +30,7 @@ pub const Section = union(enum) {
custom: []const u8, custom: []const u8,
}; };
pub fn getSection(obj: *Object, section: Section) !*std.ArrayList(u8) { pub fn getSection(obj: *Object, section: Section) !*std.array_list.Managed(u8) {
switch (obj.format) { switch (obj.format) {
.elf => return @as(*Elf, @alignCast(@fieldParentPtr("obj", obj))).getSection(section), .elf => return @as(*Elf, @alignCast(@fieldParentPtr("obj", obj))).getSection(section),
else => unreachable, else => unreachable,

View File

@ -4,7 +4,7 @@ const Target = std.Target;
const Object = @import("../Object.zig"); const Object = @import("../Object.zig");
const Section = struct { const Section = struct {
data: std.ArrayList(u8), data: std.array_list.Managed(u8),
relocations: std.ArrayListUnmanaged(Relocation) = .empty, relocations: std.ArrayListUnmanaged(Relocation) = .empty,
flags: u64, flags: u64,
type: u32, type: u32,
@ -80,12 +80,12 @@ fn sectionString(sec: Object.Section) []const u8 {
}; };
} }
pub fn getSection(elf: *Elf, section_kind: Object.Section) !*std.ArrayList(u8) { pub fn getSection(elf: *Elf, section_kind: Object.Section) !*std.array_list.Managed(u8) {
const section_name = sectionString(section_kind); const section_name = sectionString(section_kind);
const section = elf.sections.get(section_name) orelse blk: { const section = elf.sections.get(section_name) orelse blk: {
const section = try elf.arena.allocator().create(Section); const section = try elf.arena.allocator().create(Section);
section.* = .{ section.* = .{
.data = std.ArrayList(u8).init(elf.arena.child_allocator), .data = std.array_list.Managed(u8).init(elf.arena.child_allocator),
.type = std.elf.SHT_PROGBITS, .type = std.elf.SHT_PROGBITS,
.flags = switch (section_kind) { .flags = switch (section_kind) {
.func, .custom => std.elf.SHF_ALLOC + std.elf.SHF_EXECINSTR, .func, .custom => std.elf.SHF_ALLOC + std.elf.SHF_EXECINSTR,

View File

@ -116,7 +116,7 @@ pub fn translate(
var driver: aro.Driver = .{ .comp = comp }; var driver: aro.Driver = .{ .comp = comp };
defer driver.deinit(); defer driver.deinit();
var macro_buf = std.ArrayList(u8).init(gpa); var macro_buf = std.array_list.Managed(u8).init(gpa);
defer macro_buf.deinit(); defer macro_buf.deinit();
assert(!try driver.parseArgs(std.io.null_writer, macro_buf.writer(), args)); assert(!try driver.parseArgs(std.io.null_writer, macro_buf.writer(), args));
@ -413,11 +413,11 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_ty: Type) Error!void {
break :blk ZigTag.opaque_literal.init(); break :blk ZigTag.opaque_literal.init();
} }
var fields = try std.ArrayList(ast.Payload.Record.Field).initCapacity(c.gpa, record_decl.fields.len); var fields = try std.array_list.Managed(ast.Payload.Record.Field).initCapacity(c.gpa, record_decl.fields.len);
defer fields.deinit(); defer fields.deinit();
// TODO: Add support for flexible array field functions // TODO: Add support for flexible array field functions
var functions = std.ArrayList(ZigNode).init(c.gpa); var functions = std.array_list.Managed(ZigNode).init(c.gpa);
defer functions.deinit(); defer functions.deinit();
var unnamed_field_count: u32 = 0; var unnamed_field_count: u32 = 0;
@ -1234,7 +1234,7 @@ pub const PatternList = struct {
const source = template[0]; const source = template[0];
const impl = template[1]; const impl = template[1];
var tok_list = std.ArrayList(CToken).init(allocator); var tok_list = std.array_list.Managed(CToken).init(allocator);
defer tok_list.deinit(); defer tok_list.deinit();
try tokenizeMacro(source, &tok_list); try tokenizeMacro(source, &tok_list);
const tokens = try allocator.dupe(CToken, tok_list.items); const tokens = try allocator.dupe(CToken, tok_list.items);
@ -1349,7 +1349,7 @@ pub const TypeError = Error || error{UnsupportedType};
pub const TransError = TypeError || error{UnsupportedTranslation}; pub const TransError = TypeError || error{UnsupportedTranslation};
pub const SymbolTable = std.StringArrayHashMap(ast.Node); pub const SymbolTable = std.StringArrayHashMap(ast.Node);
pub const AliasList = std.ArrayList(struct { pub const AliasList = std.array_list.Managed(struct {
alias: []const u8, alias: []const u8,
name: []const u8, name: []const u8,
}); });
@ -1397,7 +1397,7 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
/// into the main arena. /// into the main arena.
pub const Block = struct { pub const Block = struct {
base: ScopeExtraScope, base: ScopeExtraScope,
statements: std.ArrayList(ast.Node), statements: std.array_list.Managed(ast.Node),
variables: AliasList, variables: AliasList,
mangle_count: u32 = 0, mangle_count: u32 = 0,
label: ?[]const u8 = null, label: ?[]const u8 = null,
@ -1429,7 +1429,7 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
.id = .block, .id = .block,
.parent = parent, .parent = parent,
}, },
.statements = std.ArrayList(ast.Node).init(c.gpa), .statements = std.array_list.Managed(ast.Node).init(c.gpa),
.variables = AliasList.init(c.gpa), .variables = AliasList.init(c.gpa),
.variable_discards = std.StringArrayHashMap(*ast.Payload.Discard).init(c.gpa), .variable_discards = std.StringArrayHashMap(*ast.Payload.Discard).init(c.gpa),
}; };
@ -1557,7 +1557,7 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
sym_table: SymbolTable, sym_table: SymbolTable,
blank_macros: std.StringArrayHashMap(void), blank_macros: std.StringArrayHashMap(void),
context: *ScopeExtraContext, context: *ScopeExtraContext,
nodes: std.ArrayList(ast.Node), nodes: std.array_list.Managed(ast.Node),
pub fn init(c: *ScopeExtraContext) Root { pub fn init(c: *ScopeExtraContext) Root {
return .{ return .{
@ -1568,7 +1568,7 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
.sym_table = SymbolTable.init(c.gpa), .sym_table = SymbolTable.init(c.gpa),
.blank_macros = std.StringArrayHashMap(void).init(c.gpa), .blank_macros = std.StringArrayHashMap(void).init(c.gpa),
.context = c, .context = c,
.nodes = std.ArrayList(ast.Node).init(c.gpa), .nodes = std.array_list.Managed(ast.Node).init(c.gpa),
}; };
} }
@ -1705,7 +1705,7 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
}; };
} }
pub fn tokenizeMacro(source: []const u8, tok_list: *std.ArrayList(CToken)) Error!void { pub fn tokenizeMacro(source: []const u8, tok_list: *std.array_list.Managed(CToken)) Error!void {
var tokenizer: aro.Tokenizer = .{ var tokenizer: aro.Tokenizer = .{
.buf = source, .buf = source,
.source = .unused, .source = .unused,
@ -1732,7 +1732,7 @@ test "Macro matching" {
const helper = struct { const helper = struct {
const MacroFunctions = std.zig.c_translation.Macros; const MacroFunctions = std.zig.c_translation.Macros;
fn checkMacro(allocator: mem.Allocator, pattern_list: PatternList, source: []const u8, comptime expected_match: ?[]const u8) !void { fn checkMacro(allocator: mem.Allocator, pattern_list: PatternList, source: []const u8, comptime expected_match: ?[]const u8) !void {
var tok_list = std.ArrayList(CToken).init(allocator); var tok_list = std.array_list.Managed(CToken).init(allocator);
defer tok_list.deinit(); defer tok_list.deinit();
try tokenizeMacro(source, &tok_list); try tokenizeMacro(source, &tok_list);
const macro_slicer: MacroSlicer = .{ .source = source, .tokens = tok_list.items }; const macro_slicer: MacroSlicer = .{ .source = source, .tokens = tok_list.items };

View File

@ -763,7 +763,7 @@ pub const Payload = struct {
pub fn render(gpa: Allocator, nodes: []const Node) !std.zig.Ast { pub fn render(gpa: Allocator, nodes: []const Node) !std.zig.Ast {
var ctx = Context{ var ctx = Context{
.gpa = gpa, .gpa = gpa,
.buf = std.ArrayList(u8).init(gpa), .buf = std.array_list.Managed(u8).init(gpa),
}; };
defer ctx.buf.deinit(); defer ctx.buf.deinit();
defer ctx.nodes.deinit(gpa); defer ctx.nodes.deinit(gpa);
@ -787,7 +787,7 @@ pub fn render(gpa: Allocator, nodes: []const Node) !std.zig.Ast {
}); });
const root_members = blk: { const root_members = blk: {
var result = std.ArrayList(NodeIndex).init(gpa); var result = std.array_list.Managed(NodeIndex).init(gpa);
defer result.deinit(); defer result.deinit();
for (nodes) |node| { for (nodes) |node| {
@ -825,7 +825,7 @@ const ExtraIndex = std.zig.Ast.ExtraIndex;
const Context = struct { const Context = struct {
gpa: Allocator, gpa: Allocator,
buf: std.ArrayList(u8), buf: std.array_list.Managed(u8),
nodes: std.zig.Ast.NodeList = .{}, nodes: std.zig.Ast.NodeList = .{},
extra_data: std.ArrayListUnmanaged(u32) = .empty, extra_data: std.ArrayListUnmanaged(u32) = .empty,
tokens: std.zig.Ast.TokenList = .{}, tokens: std.zig.Ast.TokenList = .{},
@ -886,7 +886,7 @@ const Context = struct {
}; };
fn renderNodes(c: *Context, nodes: []const Node) Allocator.Error!NodeSubRange { fn renderNodes(c: *Context, nodes: []const Node) Allocator.Error!NodeSubRange {
var result = std.ArrayList(NodeIndex).init(c.gpa); var result = std.array_list.Managed(NodeIndex).init(c.gpa);
defer result.deinit(); defer result.deinit();
for (nodes) |node| { for (nodes) |node| {
@ -1622,7 +1622,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
} }
const l_brace = try c.addToken(.l_brace, "{"); const l_brace = try c.addToken(.l_brace, "{");
var stmts = std.ArrayList(NodeIndex).init(c.gpa); var stmts = std.array_list.Managed(NodeIndex).init(c.gpa);
defer stmts.deinit(); defer stmts.deinit();
for (payload.stmts) |stmt| { for (payload.stmts) |stmt| {
const res = try renderNode(c, stmt); const res = try renderNode(c, stmt);
@ -2954,9 +2954,9 @@ fn renderMacroFunc(c: *Context, node: Node) !NodeIndex {
}); });
} }
fn renderParams(c: *Context, params: []Payload.Param, is_var_args: bool) !std.ArrayList(NodeIndex) { fn renderParams(c: *Context, params: []Payload.Param, is_var_args: bool) !std.array_list.Managed(NodeIndex) {
_ = try c.addToken(.l_paren, "("); _ = try c.addToken(.l_paren, "(");
var rendered = try std.ArrayList(NodeIndex).initCapacity(c.gpa, params.len); var rendered = try std.array_list.Managed(NodeIndex).initCapacity(c.gpa, params.len);
errdefer rendered.deinit(); errdefer rendered.deinit();
for (params, 0..) |param, i| { for (params, 0..) |param, i| {

View File

@ -5,7 +5,6 @@ const io = std.io;
const fmt = std.fmt; const fmt = std.fmt;
const mem = std.mem; const mem = std.mem;
const process = std.process; const process = std.process;
const ArrayList = std.ArrayList;
const File = std.fs.File; const File = std.fs.File;
const Step = std.Build.Step; const Step = std.Build.Step;
const Watch = std.Build.Watch; const Watch = std.Build.Watch;
@ -98,8 +97,8 @@ pub fn main() !void {
dependencies.root_deps, dependencies.root_deps,
); );
var targets = ArrayList([]const u8).init(arena); var targets = std.array_list.Managed([]const u8).init(arena);
var debug_log_scopes = ArrayList([]const u8).init(arena); var debug_log_scopes = std.array_list.Managed([]const u8).init(arena);
var thread_pool_options: std.Thread.Pool.Options = .{ .allocator = arena }; var thread_pool_options: std.Thread.Pool.Options = .{ .allocator = arena };
var install_prefix: ?[]const u8 = null; var install_prefix: ?[]const u8 = null;

View File

@ -114,10 +114,10 @@ pub fn main() !void {
interestingness_argv.appendAssumeCapacity(checker_path); interestingness_argv.appendAssumeCapacity(checker_path);
interestingness_argv.appendSliceAssumeCapacity(argv); interestingness_argv.appendSliceAssumeCapacity(argv);
var rendered = std.ArrayList(u8).init(gpa); var rendered = std.array_list.Managed(u8).init(gpa);
defer rendered.deinit(); defer rendered.deinit();
var astgen_input = std.ArrayList(u8).init(gpa); var astgen_input = std.array_list.Managed(u8).init(gpa);
defer astgen_input.deinit(); defer astgen_input.deinit();
var tree = try parse(gpa, root_source_file_path); var tree = try parse(gpa, root_source_file_path);
@ -161,7 +161,7 @@ pub fn main() !void {
// result, restart the whole process, reparsing the AST and re-generating the list // result, restart the whole process, reparsing the AST and re-generating the list
// of all possible transformations and shuffling it again. // of all possible transformations and shuffling it again.
var transformations = std.ArrayList(Walk.Transformation).init(gpa); var transformations = std.array_list.Managed(Walk.Transformation).init(gpa);
defer transformations.deinit(); defer transformations.deinit();
try Walk.findTransformations(arena, &tree, &transformations); try Walk.findTransformations(arena, &tree, &transformations);
sortTransformations(transformations.items, rng.random()); sortTransformations(transformations.items, rng.random());
@ -382,7 +382,7 @@ fn transformationsToFixups(
} }
} }
var other_source = std.ArrayList(u8).init(gpa); var other_source = std.array_list.Managed(u8).init(gpa);
defer other_source.deinit(); defer other_source.deinit();
try other_source.appendSlice("struct {\n"); try other_source.appendSlice("struct {\n");
try other_file_ast.renderToArrayList(&other_source, inlined_fixups); try other_file_ast.renderToArrayList(&other_source, inlined_fixups);

View File

@ -5,7 +5,7 @@ const assert = std.debug.assert;
const BuiltinFn = std.zig.BuiltinFn; const BuiltinFn = std.zig.BuiltinFn;
ast: *const Ast, ast: *const Ast,
transformations: *std.ArrayList(Transformation), transformations: *std.array_list.Managed(Transformation),
unreferenced_globals: std.StringArrayHashMapUnmanaged(Ast.Node.Index), unreferenced_globals: std.StringArrayHashMapUnmanaged(Ast.Node.Index),
in_scope_names: std.StringArrayHashMapUnmanaged(u32), in_scope_names: std.StringArrayHashMapUnmanaged(u32),
replace_names: std.StringArrayHashMapUnmanaged(u32), replace_names: std.StringArrayHashMapUnmanaged(u32),
@ -54,7 +54,7 @@ pub const Error = error{OutOfMemory};
pub fn findTransformations( pub fn findTransformations(
arena: std.mem.Allocator, arena: std.mem.Allocator,
ast: *const Ast, ast: *const Ast,
transformations: *std.ArrayList(Transformation), transformations: *std.array_list.Managed(Transformation),
) !void { ) !void {
transformations.clearRetainingCapacity(); transformations.clearRetainingCapacity();

View File

@ -1291,7 +1291,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn
} }
pub fn filepathWithExtension(allocator: Allocator, path: []const u8, ext: []const u8) ![]const u8 { pub fn filepathWithExtension(allocator: Allocator, path: []const u8, ext: []const u8) ![]const u8 {
var buf = std.ArrayList(u8).init(allocator); var buf = std.array_list.Managed(u8).init(allocator);
errdefer buf.deinit(); errdefer buf.deinit();
if (std.fs.path.dirname(path)) |dirname| { if (std.fs.path.dirname(path)) |dirname| {
var end_pos = dirname.len; var end_pos = dirname.len;

View File

@ -38,7 +38,7 @@ pub const CompileOptions = struct {
/// Items within the list will be allocated using the allocator of the ArrayList and must be /// Items within the list will be allocated using the allocator of the ArrayList and must be
/// freed by the caller. /// freed by the caller.
/// TODO: Maybe a dedicated struct for this purpose so that it's a bit nicer to work with. /// TODO: Maybe a dedicated struct for this purpose so that it's a bit nicer to work with.
dependencies_list: ?*std.ArrayList([]const u8) = null, dependencies_list: ?*std.array_list.Managed([]const u8) = null,
default_code_page: SupportedCodePage = .windows1252, default_code_page: SupportedCodePage = .windows1252,
/// If true, the first #pragma code_page directive only sets the input code page, but not the output code page. /// If true, the first #pragma code_page directive only sets the input code page, but not the output code page.
/// This check must be done before comments are removed from the file. /// This check must be done before comments are removed from the file.
@ -74,7 +74,7 @@ pub fn compile(allocator: Allocator, source: []const u8, writer: anytype, option
var tree = try parser.parse(allocator, options.diagnostics); var tree = try parser.parse(allocator, options.diagnostics);
defer tree.deinit(); defer tree.deinit();
var search_dirs = std.ArrayList(SearchDir).init(allocator); var search_dirs = std.array_list.Managed(SearchDir).init(allocator);
defer { defer {
for (search_dirs.items) |*search_dir| { for (search_dirs.items) |*search_dir| {
search_dir.deinit(allocator); search_dir.deinit(allocator);
@ -178,7 +178,7 @@ pub const Compiler = struct {
cwd: std.fs.Dir, cwd: std.fs.Dir,
state: State = .{}, state: State = .{},
diagnostics: *Diagnostics, diagnostics: *Diagnostics,
dependencies_list: ?*std.ArrayList([]const u8), dependencies_list: ?*std.array_list.Managed([]const u8),
input_code_pages: *const CodePageLookup, input_code_pages: *const CodePageLookup,
output_code_pages: *const CodePageLookup, output_code_pages: *const CodePageLookup,
search_dirs: []SearchDir, search_dirs: []SearchDir,
@ -279,7 +279,7 @@ pub const Compiler = struct {
.literal, .number => { .literal, .number => {
const slice = literal_node.token.slice(self.source); const slice = literal_node.token.slice(self.source);
const code_page = self.input_code_pages.getForToken(literal_node.token); const code_page = self.input_code_pages.getForToken(literal_node.token);
var buf = try std.ArrayList(u8).initCapacity(self.allocator, slice.len); var buf = try std.array_list.Managed(u8).initCapacity(self.allocator, slice.len);
errdefer buf.deinit(); errdefer buf.deinit();
var index: usize = 0; var index: usize = 0;
@ -303,7 +303,7 @@ pub const Compiler = struct {
const column = literal_node.token.calculateColumn(self.source, 8, null); const column = literal_node.token.calculateColumn(self.source, 8, null);
const bytes = SourceBytes{ .slice = slice, .code_page = self.input_code_pages.getForToken(literal_node.token) }; const bytes = SourceBytes{ .slice = slice, .code_page = self.input_code_pages.getForToken(literal_node.token) };
var buf = std.ArrayList(u8).init(self.allocator); var buf = std.array_list.Managed(u8).init(self.allocator);
errdefer buf.deinit(); errdefer buf.deinit();
// Filenames are sort-of parsed as if they were wide strings, but the max escape width of // Filenames are sort-of parsed as if they were wide strings, but the max escape width of
@ -421,7 +421,7 @@ pub const Compiler = struct {
const bytes = self.sourceBytesForToken(token); const bytes = self.sourceBytesForToken(token);
const output_code_page = self.output_code_pages.getForToken(token); const output_code_page = self.output_code_pages.getForToken(token);
var buf = try std.ArrayList(u8).initCapacity(self.allocator, bytes.slice.len); var buf = try std.array_list.Managed(u8).initCapacity(self.allocator, bytes.slice.len);
errdefer buf.deinit(); errdefer buf.deinit();
var iterative_parser = literals.IterativeStringParser.init(bytes, .{ var iterative_parser = literals.IterativeStringParser.init(bytes, .{
@ -1226,7 +1226,7 @@ pub const Compiler = struct {
} }
pub fn writeResourceRawData(self: *Compiler, node: *Node.ResourceRawData, writer: anytype) !void { pub fn writeResourceRawData(self: *Compiler, node: *Node.ResourceRawData, writer: anytype) !void {
var data_buffer = std.ArrayList(u8).init(self.allocator); var data_buffer = std.array_list.Managed(u8).init(self.allocator);
defer data_buffer.deinit(); defer data_buffer.deinit();
// The header's data length field is a u32 so limit the resource's data size so that // The header's data length field is a u32 so limit the resource's data size so that
// we know we can always specify the real size. // we know we can always specify the real size.
@ -1306,7 +1306,7 @@ pub const Compiler = struct {
} }
pub fn writeAccelerators(self: *Compiler, node: *Node.Accelerators, writer: anytype) !void { pub fn writeAccelerators(self: *Compiler, node: *Node.Accelerators, writer: anytype) !void {
var data_buffer = std.ArrayList(u8).init(self.allocator); var data_buffer = std.array_list.Managed(u8).init(self.allocator);
defer data_buffer.deinit(); defer data_buffer.deinit();
// The header's data length field is a u32 so limit the resource's data size so that // The header's data length field is a u32 so limit the resource's data size so that
@ -1405,7 +1405,7 @@ pub const Compiler = struct {
}; };
pub fn writeDialog(self: *Compiler, node: *Node.Dialog, writer: anytype) !void { pub fn writeDialog(self: *Compiler, node: *Node.Dialog, writer: anytype) !void {
var data_buffer = std.ArrayList(u8).init(self.allocator); var data_buffer = std.array_list.Managed(u8).init(self.allocator);
defer data_buffer.deinit(); defer data_buffer.deinit();
// The header's data length field is a u32 so limit the resource's data size so that // The header's data length field is a u32 so limit the resource's data size so that
// we know we can always specify the real size. // we know we can always specify the real size.
@ -1973,7 +1973,7 @@ pub const Compiler = struct {
try NameOrOrdinal.writeEmpty(data_writer); try NameOrOrdinal.writeEmpty(data_writer);
} }
var extra_data_buf = std.ArrayList(u8).init(self.allocator); var extra_data_buf = std.array_list.Managed(u8).init(self.allocator);
defer extra_data_buf.deinit(); defer extra_data_buf.deinit();
// The extra data byte length must be able to fit within a u16. // The extra data byte length must be able to fit within a u16.
var limited_extra_data_writer = limitedWriter(extra_data_buf.writer(), std.math.maxInt(u16)); var limited_extra_data_writer = limitedWriter(extra_data_buf.writer(), std.math.maxInt(u16));
@ -2004,7 +2004,7 @@ pub const Compiler = struct {
} }
pub fn writeToolbar(self: *Compiler, node: *Node.Toolbar, writer: anytype) !void { pub fn writeToolbar(self: *Compiler, node: *Node.Toolbar, writer: anytype) !void {
var data_buffer = std.ArrayList(u8).init(self.allocator); var data_buffer = std.array_list.Managed(u8).init(self.allocator);
defer data_buffer.deinit(); defer data_buffer.deinit();
const data_writer = data_buffer.writer(); const data_writer = data_buffer.writer();
@ -2082,7 +2082,7 @@ pub const Compiler = struct {
} }
pub fn writeMenu(self: *Compiler, node: *Node.Menu, writer: anytype) !void { pub fn writeMenu(self: *Compiler, node: *Node.Menu, writer: anytype) !void {
var data_buffer = std.ArrayList(u8).init(self.allocator); var data_buffer = std.array_list.Managed(u8).init(self.allocator);
defer data_buffer.deinit(); defer data_buffer.deinit();
// The header's data length field is a u32 so limit the resource's data size so that // The header's data length field is a u32 so limit the resource's data size so that
// we know we can always specify the real size. // we know we can always specify the real size.
@ -2265,7 +2265,7 @@ pub const Compiler = struct {
} }
pub fn writeVersionInfo(self: *Compiler, node: *Node.VersionInfo, writer: anytype) !void { pub fn writeVersionInfo(self: *Compiler, node: *Node.VersionInfo, writer: anytype) !void {
var data_buffer = std.ArrayList(u8).init(self.allocator); var data_buffer = std.array_list.Managed(u8).init(self.allocator);
defer data_buffer.deinit(); defer data_buffer.deinit();
// The node's length field (which is inclusive of the length of all of its children) is a u16 // The node's length field (which is inclusive of the length of all of its children) is a u16
// so limit the node's data size so that we know we can always specify the real size. // so limit the node's data size so that we know we can always specify the real size.
@ -2394,7 +2394,7 @@ pub const Compiler = struct {
/// Expects writer to be a LimitedWriter limited to u16, meaning all writes to /// Expects writer to be a LimitedWriter limited to u16, meaning all writes to
/// the writer within this function could return error.NoSpaceLeft, and that buf.items.len /// the writer within this function could return error.NoSpaceLeft, and that buf.items.len
/// will never be able to exceed maxInt(u16). /// will never be able to exceed maxInt(u16).
pub fn writeVersionNode(self: *Compiler, node: *Node, writer: *std.Io.Writer, buf: *std.ArrayList(u8)) !void { pub fn writeVersionNode(self: *Compiler, node: *Node, writer: *std.Io.Writer, buf: *std.array_list.Managed(u8)) !void {
// We can assume that buf.items.len will never be able to exceed the limits of a u16 // We can assume that buf.items.len will never be able to exceed the limits of a u16
try writeDataPadding(writer, @as(u16, @intCast(buf.items.len))); try writeDataPadding(writer, @as(u16, @intCast(buf.items.len)));
@ -3246,7 +3246,7 @@ pub const StringTable = struct {
} }
pub fn writeResData(self: *Block, compiler: *Compiler, language: res.Language, block_id: u16, writer: anytype) !void { pub fn writeResData(self: *Block, compiler: *Compiler, language: res.Language, block_id: u16, writer: anytype) !void {
var data_buffer = std.ArrayList(u8).init(compiler.allocator); var data_buffer = std.array_list.Managed(u8).init(compiler.allocator);
defer data_buffer.deinit(); defer data_buffer.deinit();
const data_writer = data_buffer.writer(); const data_writer = data_buffer.writer();

View File

@ -56,7 +56,7 @@ pub fn readAnyError(allocator: std.mem.Allocator, reader: anytype, max_size: u64
// entries than it actually does, we use an ArrayList with a conservatively // entries than it actually does, we use an ArrayList with a conservatively
// limited initial capacity instead of allocating the entire slice at once. // limited initial capacity instead of allocating the entire slice at once.
const initial_capacity = @min(num_images, 8); const initial_capacity = @min(num_images, 8);
var entries = try std.ArrayList(Entry).initCapacity(allocator, initial_capacity); var entries = try std.array_list.Managed(Entry).initCapacity(allocator, initial_capacity);
errdefer entries.deinit(); errdefer entries.deinit();
var i: usize = 0; var i: usize = 0;

View File

@ -469,7 +469,7 @@ pub fn parseQuotedString(
const T = if (literal_type == .ascii) u8 else u16; const T = if (literal_type == .ascii) u8 else u16;
std.debug.assert(bytes.slice.len >= 2); // must at least have 2 double quote chars std.debug.assert(bytes.slice.len >= 2); // must at least have 2 double quote chars
var buf = try std.ArrayList(T).initCapacity(allocator, bytes.slice.len); var buf = try std.array_list.Managed(T).initCapacity(allocator, bytes.slice.len);
errdefer buf.deinit(); errdefer buf.deinit();
var iterative_parser = IterativeStringParser.init(bytes, options); var iterative_parser = IterativeStringParser.init(bytes, options);
@ -564,7 +564,7 @@ pub fn parseQuotedStringAsWideString(allocator: std.mem.Allocator, bytes: Source
// Note: We're only handling the case of parsing an ASCII string into a wide string from here on out. // Note: We're only handling the case of parsing an ASCII string into a wide string from here on out.
// TODO: The logic below is similar to that in AcceleratorKeyCodepointTranslator, might be worth merging the two // TODO: The logic below is similar to that in AcceleratorKeyCodepointTranslator, might be worth merging the two
var buf = try std.ArrayList(u16).initCapacity(allocator, bytes.slice.len); var buf = try std.array_list.Managed(u16).initCapacity(allocator, bytes.slice.len);
errdefer buf.deinit(); errdefer buf.deinit();
var iterative_parser = IterativeStringParser.init(bytes, options); var iterative_parser = IterativeStringParser.init(bytes, options);

View File

@ -97,14 +97,14 @@ pub fn main() !void {
try stdout_writer.writeByte('\n'); try stdout_writer.writeByte('\n');
} }
var dependencies_list = std.ArrayList([]const u8).init(allocator); var dependencies_list = std.array_list.Managed([]const u8).init(allocator);
defer { defer {
for (dependencies_list.items) |item| { for (dependencies_list.items) |item| {
allocator.free(item); allocator.free(item);
} }
dependencies_list.deinit(); dependencies_list.deinit();
} }
const maybe_dependencies_list: ?*std.ArrayList([]const u8) = if (options.depfile_path != null) &dependencies_list else null; const maybe_dependencies_list: ?*std.array_list.Managed([]const u8) = if (options.depfile_path != null) &dependencies_list else null;
var include_paths = LazyIncludePaths{ var include_paths = LazyIncludePaths{
.arena = arena, .arena = arena,
@ -115,7 +115,7 @@ pub fn main() !void {
const full_input = full_input: { const full_input = full_input: {
if (options.input_format == .rc and options.preprocess != .no) { if (options.input_format == .rc and options.preprocess != .no) {
var preprocessed_buf = std.ArrayList(u8).init(allocator); var preprocessed_buf = std.array_list.Managed(u8).init(allocator);
errdefer preprocessed_buf.deinit(); errdefer preprocessed_buf.deinit();
// We're going to throw away everything except the final preprocessed output anyway, // We're going to throw away everything except the final preprocessed output anyway,
@ -127,7 +127,7 @@ pub fn main() !void {
var comp = aro.Compilation.init(aro_arena, std.fs.cwd()); var comp = aro.Compilation.init(aro_arena, std.fs.cwd());
defer comp.deinit(); defer comp.deinit();
var argv = std.ArrayList([]const u8).init(comp.gpa); var argv = std.array_list.Managed([]const u8).init(comp.gpa);
defer argv.deinit(); defer argv.deinit();
try argv.append("arocc"); // dummy command name try argv.append("arocc"); // dummy command name
@ -946,7 +946,7 @@ fn aroDiagnosticsToErrorBundle(
// - Only prints the message itself (no location, source line, error: prefix, etc) // - Only prints the message itself (no location, source line, error: prefix, etc)
// - Keeps track of source path/line/col instead // - Keeps track of source path/line/col instead
const MsgWriter = struct { const MsgWriter = struct {
buf: std.ArrayList(u8), buf: std.array_list.Managed(u8),
path: ?[]const u8 = null, path: ?[]const u8 = null,
// 1-indexed // 1-indexed
line: u32 = undefined, line: u32 = undefined,
@ -956,7 +956,7 @@ const MsgWriter = struct {
fn init(allocator: std.mem.Allocator) MsgWriter { fn init(allocator: std.mem.Allocator) MsgWriter {
return .{ return .{
.buf = std.ArrayList(u8).init(allocator), .buf = std.array_list.Managed(u8).init(allocator),
}; };
} }

View File

@ -82,7 +82,7 @@ pub const Parser = struct {
} }
fn parseRoot(self: *Self) Error!*Node { fn parseRoot(self: *Self) Error!*Node {
var statements = std.ArrayList(*Node).init(self.state.allocator); var statements = std.array_list.Managed(*Node).init(self.state.allocator);
defer statements.deinit(); defer statements.deinit();
try self.parseStatements(&statements); try self.parseStatements(&statements);
@ -95,7 +95,7 @@ pub const Parser = struct {
return &node.base; return &node.base;
} }
fn parseStatements(self: *Self, statements: *std.ArrayList(*Node)) Error!void { fn parseStatements(self: *Self, statements: *std.array_list.Managed(*Node)) Error!void {
while (true) { while (true) {
try self.nextToken(.whitespace_delimiter_only); try self.nextToken(.whitespace_delimiter_only);
if (self.state.token.id == .eof) break; if (self.state.token.id == .eof) break;
@ -355,7 +355,7 @@ pub const Parser = struct {
const begin_token = self.state.token; const begin_token = self.state.token;
try self.check(.begin); try self.check(.begin);
var strings = std.ArrayList(*Node).init(self.state.allocator); var strings = std.array_list.Managed(*Node).init(self.state.allocator);
defer strings.deinit(); defer strings.deinit();
while (true) { while (true) {
const maybe_end_token = try self.lookaheadToken(.normal); const maybe_end_token = try self.lookaheadToken(.normal);
@ -852,7 +852,7 @@ pub const Parser = struct {
/// Expects the current token to be a begin token. /// Expects the current token to be a begin token.
/// After return, the current token will be the end token. /// After return, the current token will be the end token.
fn parseRawDataBlock(self: *Self) Error![]*Node { fn parseRawDataBlock(self: *Self) Error![]*Node {
var raw_data = std.ArrayList(*Node).init(self.state.allocator); var raw_data = std.array_list.Managed(*Node).init(self.state.allocator);
defer raw_data.deinit(); defer raw_data.deinit();
while (true) { while (true) {
const maybe_end_token = try self.lookaheadToken(.normal); const maybe_end_token = try self.lookaheadToken(.normal);

View File

@ -11,14 +11,14 @@ pub fn preprocess(
writer: anytype, writer: anytype,
/// Expects argv[0] to be the command name /// Expects argv[0] to be the command name
argv: []const []const u8, argv: []const []const u8,
maybe_dependencies_list: ?*std.ArrayList([]const u8), maybe_dependencies_list: ?*std.array_list.Managed([]const u8),
) PreprocessError!void { ) PreprocessError!void {
try comp.addDefaultPragmaHandlers(); try comp.addDefaultPragmaHandlers();
var driver: aro.Driver = .{ .comp = comp, .aro_name = "arocc" }; var driver: aro.Driver = .{ .comp = comp, .aro_name = "arocc" };
defer driver.deinit(); defer driver.deinit();
var macro_buf = std.ArrayList(u8).init(comp.gpa); var macro_buf = std.array_list.Managed(u8).init(comp.gpa);
defer macro_buf.deinit(); defer macro_buf.deinit();
_ = driver.parseArgs(std.io.null_writer, macro_buf.writer(), argv) catch |err| switch (err) { _ = driver.parseArgs(std.io.null_writer, macro_buf.writer(), argv) catch |err| switch (err) {
@ -87,7 +87,7 @@ fn hasAnyErrors(comp: *aro.Compilation) bool {
/// `arena` is used for temporary -D argument strings and the INCLUDE environment variable. /// `arena` is used for temporary -D argument strings and the INCLUDE environment variable.
/// The arena should be kept alive at least as long as `argv`. /// The arena should be kept alive at least as long as `argv`.
pub fn appendAroArgs(arena: Allocator, argv: *std.ArrayList([]const u8), options: cli.Options, system_include_paths: []const []const u8) !void { pub fn appendAroArgs(arena: Allocator, argv: *std.array_list.Managed([]const u8), options: cli.Options, system_include_paths: []const []const u8) !void {
try argv.appendSlice(&.{ try argv.appendSlice(&.{
"-E", "-E",
"--comments", "--comments",

View File

@ -283,7 +283,7 @@ pub const NameOrOrdinal = union(enum) {
pub fn nameFromString(allocator: Allocator, bytes: SourceBytes) !NameOrOrdinal { pub fn nameFromString(allocator: Allocator, bytes: SourceBytes) !NameOrOrdinal {
// Names have a limit of 256 UTF-16 code units + null terminator // Names have a limit of 256 UTF-16 code units + null terminator
var buf = try std.ArrayList(u16).initCapacity(allocator, @min(257, bytes.slice.len)); var buf = try std.array_list.Managed(u16).initCapacity(allocator, @min(257, bytes.slice.len));
errdefer buf.deinit(); errdefer buf.deinit();
var i: usize = 0; var i: usize = 0;

View File

@ -574,7 +574,7 @@ fn parseFilename(allocator: Allocator, str: []const u8) error{ OutOfMemory, Inva
escape_u, escape_u,
}; };
var filename = try std.ArrayList(u8).initCapacity(allocator, str.len); var filename = try std.array_list.Managed(u8).initCapacity(allocator, str.len);
errdefer filename.deinit(); errdefer filename.deinit();
var state: State = .string; var state: State = .string;
var index: usize = 0; var index: usize = 0;

View File

@ -574,7 +574,7 @@ pub fn bestFitFromCodepoint(codepoint: u21) ?u8 {
} }
test "windows-1252 to utf8" { test "windows-1252 to utf8" {
var buf = std.ArrayList(u8).init(std.testing.allocator); var buf = std.array_list.Managed(u8).init(std.testing.allocator);
defer buf.deinit(); defer buf.deinit();
const input_windows1252 = "\x81pqrstuvwxyz{|}~\x80\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8e\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9e\x9f\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"; const input_windows1252 = "\x81pqrstuvwxyz{|}~\x80\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8e\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9e\x9f\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff";

View File

@ -1119,7 +1119,7 @@ fn testRender(input: []const u8, expected: []const u8) !void {
var doc = try parser.endInput(); var doc = try parser.endInput();
defer doc.deinit(testing.allocator); defer doc.deinit(testing.allocator);
var actual = std.ArrayList(u8).init(testing.allocator); var actual = std.array_list.Managed(u8).init(testing.allocator);
defer actual.deinit(); defer actual.deinit();
try doc.render(actual.writer()); try doc.render(actual.writer());

View File

@ -8,9 +8,10 @@ pub fn main() !void {
} }
test "simple test" { test "simple test" {
var list = std.ArrayList(i32).init(std.testing.allocator); const gpa = std.testing.allocator;
defer list.deinit(); // Try commenting this out and see if zig detects the memory leak! var list: std.ArrayList(i32) = .empty;
try list.append(42); defer list.deinit(gpa); // Try commenting this out and see if zig detects the memory leak!
try list.append(gpa, 42);
try std.testing.expectEqual(@as(i32, 42), list.pop()); try std.testing.expectEqual(@as(i32, 42), list.pop());
} }

View File

@ -4,14 +4,14 @@ const BitStack = @This();
const std = @import("std"); const std = @import("std");
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList; const ArrayList = std.array_list.Managed;
bytes: std.ArrayList(u8), bytes: std.array_list.Managed(u8),
bit_len: usize = 0, bit_len: usize = 0,
pub fn init(allocator: Allocator) @This() { pub fn init(allocator: Allocator) @This() {
return .{ return .{
.bytes = std.ArrayList(u8).init(allocator), .bytes = std.array_list.Managed(u8).init(allocator),
}; };
} }

View File

@ -7,7 +7,6 @@ const debug = std.debug;
const panic = std.debug.panic; const panic = std.debug.panic;
const assert = debug.assert; const assert = debug.assert;
const log = std.log; const log = std.log;
const ArrayList = std.ArrayList;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const Allocator = mem.Allocator; const Allocator = mem.Allocator;
const Target = std.Target; const Target = std.Target;
@ -16,6 +15,7 @@ const EnvMap = std.process.EnvMap;
const File = fs.File; const File = fs.File;
const Sha256 = std.crypto.hash.sha2.Sha256; const Sha256 = std.crypto.hash.sha2.Sha256;
const Build = @This(); const Build = @This();
const ArrayList = std.ArrayList;
pub const Cache = @import("Build/Cache.zig"); pub const Cache = @import("Build/Cache.zig");
pub const Step = @import("Build/Step.zig"); pub const Step = @import("Build/Step.zig");
@ -32,7 +32,7 @@ uninstall_tls: TopLevelStep,
allocator: Allocator, allocator: Allocator,
user_input_options: UserInputOptionsMap, user_input_options: UserInputOptionsMap,
available_options_map: AvailableOptionsMap, available_options_map: AvailableOptionsMap,
available_options_list: ArrayList(AvailableOption), available_options_list: std.array_list.Managed(AvailableOption),
verbose: bool, verbose: bool,
verbose_link: bool, verbose_link: bool,
verbose_cc: bool, verbose_cc: bool,
@ -52,7 +52,7 @@ exe_dir: []const u8,
h_dir: []const u8, h_dir: []const u8,
install_path: []const u8, install_path: []const u8,
sysroot: ?[]const u8 = null, sysroot: ?[]const u8 = null,
search_prefixes: std.ArrayListUnmanaged([]const u8), search_prefixes: ArrayList([]const u8),
libc_file: ?[]const u8 = null, libc_file: ?[]const u8 = null,
/// Path to the directory containing build.zig. /// Path to the directory containing build.zig.
build_root: Cache.Directory, build_root: Cache.Directory,
@ -220,10 +220,10 @@ const UserInputOption = struct {
const UserValue = union(enum) { const UserValue = union(enum) {
flag: void, flag: void,
scalar: []const u8, scalar: []const u8,
list: ArrayList([]const u8), list: std.array_list.Managed([]const u8),
map: StringHashMap(*const UserValue), map: StringHashMap(*const UserValue),
lazy_path: LazyPath, lazy_path: LazyPath,
lazy_path_list: ArrayList(LazyPath), lazy_path_list: std.array_list.Managed(LazyPath),
}; };
const TypeId = enum { const TypeId = enum {
@ -277,10 +277,10 @@ pub fn create(
.allocator = arena, .allocator = arena,
.user_input_options = UserInputOptionsMap.init(arena), .user_input_options = UserInputOptionsMap.init(arena),
.available_options_map = AvailableOptionsMap.init(arena), .available_options_map = AvailableOptionsMap.init(arena),
.available_options_list = ArrayList(AvailableOption).init(arena), .available_options_list = std.array_list.Managed(AvailableOption).init(arena),
.top_level_steps = .{}, .top_level_steps = .{},
.default_step = undefined, .default_step = undefined,
.search_prefixes = .{}, .search_prefixes = .empty,
.install_prefix = undefined, .install_prefix = undefined,
.lib_dir = undefined, .lib_dir = undefined,
.exe_dir = undefined, .exe_dir = undefined,
@ -363,7 +363,7 @@ fn createChildOnly(
}, },
.user_input_options = user_input_options, .user_input_options = user_input_options,
.available_options_map = AvailableOptionsMap.init(allocator), .available_options_map = AvailableOptionsMap.init(allocator),
.available_options_list = ArrayList(AvailableOption).init(allocator), .available_options_list = std.array_list.Managed(AvailableOption).init(allocator),
.verbose = parent.verbose, .verbose = parent.verbose,
.verbose_link = parent.verbose_link, .verbose_link = parent.verbose_link,
.verbose_cc = parent.verbose_cc, .verbose_cc = parent.verbose_cc,
@ -468,7 +468,7 @@ fn addUserInputOptionFromArg(
}) catch @panic("OOM"); }) catch @panic("OOM");
}, },
[]const LazyPath => return if (maybe_value) |v| { []const LazyPath => return if (maybe_value) |v| {
var list = ArrayList(LazyPath).initCapacity(arena, v.len) catch @panic("OOM"); var list = std.array_list.Managed(LazyPath).initCapacity(arena, v.len) catch @panic("OOM");
for (v) |lp| list.appendAssumeCapacity(lp.dupeInner(arena)); for (v) |lp| list.appendAssumeCapacity(lp.dupeInner(arena));
map.put(field.name, .{ map.put(field.name, .{
.name = field.name, .name = field.name,
@ -484,7 +484,7 @@ fn addUserInputOptionFromArg(
}) catch @panic("OOM"); }) catch @panic("OOM");
}, },
[]const []const u8 => return if (maybe_value) |v| { []const []const u8 => return if (maybe_value) |v| {
var list = ArrayList([]const u8).initCapacity(arena, v.len) catch @panic("OOM"); var list = std.array_list.Managed([]const u8).initCapacity(arena, v.len) catch @panic("OOM");
for (v) |s| list.appendAssumeCapacity(arena.dupe(u8, s) catch @panic("OOM")); for (v) |s| list.appendAssumeCapacity(arena.dupe(u8, s) catch @panic("OOM"));
map.put(field.name, .{ map.put(field.name, .{
.name = field.name, .name = field.name,
@ -542,7 +542,7 @@ fn addUserInputOptionFromArg(
}, },
.slice => switch (@typeInfo(ptr_info.child)) { .slice => switch (@typeInfo(ptr_info.child)) {
.@"enum" => return if (maybe_value) |v| { .@"enum" => return if (maybe_value) |v| {
var list = ArrayList([]const u8).initCapacity(arena, v.len) catch @panic("OOM"); var list = std.array_list.Managed([]const u8).initCapacity(arena, v.len) catch @panic("OOM");
for (v) |tag| list.appendAssumeCapacity(@tagName(tag)); for (v) |tag| list.appendAssumeCapacity(@tagName(tag));
map.put(field.name, .{ map.put(field.name, .{
.name = field.name, .name = field.name,
@ -589,10 +589,10 @@ fn addUserInputOptionFromArg(
const OrderedUserValue = union(enum) { const OrderedUserValue = union(enum) {
flag: void, flag: void,
scalar: []const u8, scalar: []const u8,
list: ArrayList([]const u8), list: std.array_list.Managed([]const u8),
map: ArrayList(Pair), map: std.array_list.Managed(Pair),
lazy_path: LazyPath, lazy_path: LazyPath,
lazy_path_list: ArrayList(LazyPath), lazy_path_list: std.array_list.Managed(LazyPath),
const Pair = struct { const Pair = struct {
name: []const u8, name: []const u8,
@ -642,8 +642,8 @@ const OrderedUserValue = union(enum) {
} }
} }
fn mapFromUnordered(allocator: Allocator, unordered: std.StringHashMap(*const UserValue)) ArrayList(Pair) { fn mapFromUnordered(allocator: Allocator, unordered: std.StringHashMap(*const UserValue)) std.array_list.Managed(Pair) {
var ordered = ArrayList(Pair).init(allocator); var ordered = std.array_list.Managed(Pair).init(allocator);
var it = unordered.iterator(); var it = unordered.iterator();
while (it.next()) |entry| { while (it.next()) |entry| {
ordered.append(.{ ordered.append(.{
@ -694,7 +694,7 @@ const OrderedUserInputOption = struct {
// The hash should be consistent with the same values given a different order. // The hash should be consistent with the same values given a different order.
// This function takes a user input map, orders it, then hashes the contents. // This function takes a user input map, orders it, then hashes the contents.
fn hashUserInputOptionsMap(allocator: Allocator, user_input_options: UserInputOptionsMap, hasher: *std.hash.Wyhash) void { fn hashUserInputOptionsMap(allocator: Allocator, user_input_options: UserInputOptionsMap, hasher: *std.hash.Wyhash) void {
var ordered = ArrayList(OrderedUserInputOption).init(allocator); var ordered = std.array_list.Managed(OrderedUserInputOption).init(allocator);
var it = user_input_options.iterator(); var it = user_input_options.iterator();
while (it.next()) |entry| while (it.next()) |entry|
ordered.append(OrderedUserInputOption.fromUnordered(allocator, entry.value_ptr.*)) catch @panic("OOM"); ordered.append(OrderedUserInputOption.fromUnordered(allocator, entry.value_ptr.*)) catch @panic("OOM");
@ -1086,7 +1086,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw
const enum_options = if (type_id == .@"enum" or type_id == .enum_list) blk: { const enum_options = if (type_id == .@"enum" or type_id == .enum_list) blk: {
const EnumType = if (type_id == .enum_list) @typeInfo(T).pointer.child else T; const EnumType = if (type_id == .enum_list) @typeInfo(T).pointer.child else T;
const fields = comptime std.meta.fields(EnumType); const fields = comptime std.meta.fields(EnumType);
var options = ArrayList([]const u8).initCapacity(b.allocator, fields.len) catch @panic("OOM"); var options = std.array_list.Managed([]const u8).initCapacity(b.allocator, fields.len) catch @panic("OOM");
inline for (fields) |field| { inline for (fields) |field| {
options.appendAssumeCapacity(field.name); options.appendAssumeCapacity(field.name);
@ -1488,7 +1488,7 @@ pub fn addUserInputOption(b: *Build, name_raw: []const u8, value_raw: []const u8
switch (gop.value_ptr.value) { switch (gop.value_ptr.value) {
.scalar => |s| { .scalar => |s| {
// turn it into a list // turn it into a list
var list = ArrayList([]const u8).init(b.allocator); var list = std.array_list.Managed([]const u8).init(b.allocator);
try list.append(s); try list.append(s);
try list.append(value); try list.append(value);
try b.user_input_options.put(name, .{ try b.user_input_options.put(name, .{
@ -1596,7 +1596,7 @@ pub fn validateUserInputDidItFail(b: *Build) bool {
} }
fn allocPrintCmd(gpa: Allocator, opt_cwd: ?[]const u8, argv: []const []const u8) error{OutOfMemory}![]u8 { fn allocPrintCmd(gpa: Allocator, opt_cwd: ?[]const u8, argv: []const []const u8) error{OutOfMemory}![]u8 {
var buf: std.ArrayListUnmanaged(u8) = .empty; var buf: ArrayList(u8) = .empty;
if (opt_cwd) |cwd| try buf.print(gpa, "cd {s} && ", .{cwd}); if (opt_cwd) |cwd| try buf.print(gpa, "cd {s} && ", .{cwd});
for (argv) |arg| { for (argv) |arg| {
try buf.print(gpa, "{s} ", .{arg}); try buf.print(gpa, "{s} ", .{arg});

View File

@ -10,12 +10,12 @@ resolved_target: ?std.Build.ResolvedTarget = null,
optimize: ?std.builtin.OptimizeMode = null, optimize: ?std.builtin.OptimizeMode = null,
dwarf_format: ?std.dwarf.Format, dwarf_format: ?std.dwarf.Format,
c_macros: std.ArrayListUnmanaged([]const u8), c_macros: ArrayList([]const u8),
include_dirs: std.ArrayListUnmanaged(IncludeDir), include_dirs: ArrayList(IncludeDir),
lib_paths: std.ArrayListUnmanaged(LazyPath), lib_paths: ArrayList(LazyPath),
rpaths: std.ArrayListUnmanaged(RPath), rpaths: ArrayList(RPath),
frameworks: std.StringArrayHashMapUnmanaged(LinkFrameworkOptions), frameworks: std.StringArrayHashMapUnmanaged(LinkFrameworkOptions),
link_objects: std.ArrayListUnmanaged(LinkObject), link_objects: ArrayList(LinkObject),
strip: ?bool, strip: ?bool,
unwind_tables: ?std.builtin.UnwindTables, unwind_tables: ?std.builtin.UnwindTables,
@ -170,7 +170,7 @@ pub const IncludeDir = union(enum) {
pub fn appendZigProcessFlags( pub fn appendZigProcessFlags(
include_dir: IncludeDir, include_dir: IncludeDir,
b: *std.Build, b: *std.Build,
zig_args: *std.ArrayList([]const u8), zig_args: *std.array_list.Managed([]const u8),
asking_step: ?*Step, asking_step: ?*Step,
) !void { ) !void {
const flag: []const u8, const lazy_path: LazyPath = switch (include_dir) { const flag: []const u8, const lazy_path: LazyPath = switch (include_dir) {
@ -537,7 +537,7 @@ pub fn addCMacro(m: *Module, name: []const u8, value: []const u8) void {
pub fn appendZigProcessFlags( pub fn appendZigProcessFlags(
m: *Module, m: *Module,
zig_args: *std.ArrayList([]const u8), zig_args: *std.array_list.Managed([]const u8),
asking_step: ?*Step, asking_step: ?*Step,
) !void { ) !void {
const b = m.owner; const b = m.owner;
@ -634,7 +634,7 @@ pub fn appendZigProcessFlags(
} }
fn addFlag( fn addFlag(
args: *std.ArrayList([]const u8), args: *std.array_list.Managed([]const u8),
opt: ?bool, opt: ?bool,
then_name: []const u8, then_name: []const u8,
else_name: []const u8, else_name: []const u8,
@ -706,3 +706,4 @@ const std = @import("std");
const assert = std.debug.assert; const assert = std.debug.assert;
const LazyPath = std.Build.LazyPath; const LazyPath = std.Build.LazyPath;
const Step = std.Build.Step; const Step = std.Build.Step;
const ArrayList = std.ArrayList;

View File

@ -1,12 +1,22 @@
const Step = @This();
const std = @import("../std.zig");
const Build = std.Build;
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const builtin = @import("builtin");
const Cache = Build.Cache;
const Path = Cache.Path;
const ArrayList = std.ArrayList;
id: Id, id: Id,
name: []const u8, name: []const u8,
owner: *Build, owner: *Build,
makeFn: MakeFn, makeFn: MakeFn,
dependencies: std.ArrayList(*Step), dependencies: std.array_list.Managed(*Step),
/// This field is empty during execution of the user's build script, and /// This field is empty during execution of the user's build script, and
/// then populated during dependency loop checking in the build runner. /// then populated during dependency loop checking in the build runner.
dependants: std.ArrayListUnmanaged(*Step), dependants: ArrayList(*Step),
/// Collects the set of files that retrigger this step to run. /// Collects the set of files that retrigger this step to run.
/// ///
/// This is used by the build system's implementation of `--watch` but it can /// This is used by the build system's implementation of `--watch` but it can
@ -39,7 +49,7 @@ state: State,
/// total system memory available. /// total system memory available.
max_rss: usize, max_rss: usize,
result_error_msgs: std.ArrayListUnmanaged([]const u8), result_error_msgs: ArrayList([]const u8),
result_error_bundle: std.zig.ErrorBundle, result_error_bundle: std.zig.ErrorBundle,
result_stderr: []const u8, result_stderr: []const u8,
result_cached: bool, result_cached: bool,
@ -175,7 +185,7 @@ pub const Inputs = struct {
pub const Table = std.ArrayHashMapUnmanaged(Build.Cache.Path, Files, Build.Cache.Path.TableAdapter, false); pub const Table = std.ArrayHashMapUnmanaged(Build.Cache.Path, Files, Build.Cache.Path.TableAdapter, false);
/// The special file name "." means any changes inside the directory. /// The special file name "." means any changes inside the directory.
pub const Files = std.ArrayListUnmanaged([]const u8); pub const Files = ArrayList([]const u8);
pub fn populated(inputs: *Inputs) bool { pub fn populated(inputs: *Inputs) bool {
return inputs.table.count() != 0; return inputs.table.count() != 0;
@ -204,8 +214,8 @@ pub fn init(options: StepOptions) Step {
.name = arena.dupe(u8, options.name) catch @panic("OOM"), .name = arena.dupe(u8, options.name) catch @panic("OOM"),
.owner = options.owner, .owner = options.owner,
.makeFn = options.makeFn, .makeFn = options.makeFn,
.dependencies = std.ArrayList(*Step).init(arena), .dependencies = std.array_list.Managed(*Step).init(arena),
.dependants = .{}, .dependants = .empty,
.inputs = Inputs.init, .inputs = Inputs.init,
.state = .precheck_unstarted, .state = .precheck_unstarted,
.max_rss = options.max_rss, .max_rss = options.max_rss,
@ -326,15 +336,6 @@ pub fn dump(step: *Step, w: *std.Io.Writer, tty_config: std.Io.tty.Config) void
} }
} }
const Step = @This();
const std = @import("../std.zig");
const Build = std.Build;
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const builtin = @import("builtin");
const Cache = Build.Cache;
const Path = Cache.Path;
pub fn evalChildProcess(s: *Step, argv: []const []const u8) ![]u8 { pub fn evalChildProcess(s: *Step, argv: []const []const u8) ![]u8 {
const run_result = try captureChildProcess(s, std.Progress.Node.none, argv); const run_result = try captureChildProcess(s, std.Progress.Node.none, argv);
try handleChildProcessTerm(s, run_result.term, null, argv); try handleChildProcessTerm(s, run_result.term, null, argv);
@ -980,7 +981,7 @@ fn addDirectoryWatchInputFromBuilder(step: *Step, builder: *Build, sub_path: []c
fn addWatchInputFromPath(step: *Step, path: Build.Cache.Path, basename: []const u8) !void { fn addWatchInputFromPath(step: *Step, path: Build.Cache.Path, basename: []const u8) !void {
const gpa = step.owner.allocator; const gpa = step.owner.allocator;
const gop = try step.inputs.table.getOrPut(gpa, path); const gop = try step.inputs.table.getOrPut(gpa, path);
if (!gop.found_existing) gop.value_ptr.* = .{}; if (!gop.found_existing) gop.value_ptr.* = .empty;
try gop.value_ptr.append(gpa, basename); try gop.value_ptr.append(gpa, basename);
} }

View File

@ -18,7 +18,7 @@ pub const base_id: Step.Id = .check_object;
step: Step, step: Step,
source: std.Build.LazyPath, source: std.Build.LazyPath,
max_bytes: usize = 20 * 1024 * 1024, max_bytes: usize = 20 * 1024 * 1024,
checks: std.ArrayList(Check), checks: std.array_list.Managed(Check),
obj_format: std.Target.ObjectFormat, obj_format: std.Target.ObjectFormat,
pub fn create( pub fn create(
@ -36,7 +36,7 @@ pub fn create(
.makeFn = make, .makeFn = make,
}), }),
.source = source.dupe(owner), .source = source.dupe(owner),
.checks = std.ArrayList(Check).init(gpa), .checks = std.array_list.Managed(Check).init(gpa),
.obj_format = obj_format, .obj_format = obj_format,
}; };
check_object.source.addStepDependencies(&check_object.step); check_object.source.addStepDependencies(&check_object.step);
@ -81,7 +81,7 @@ const Action = struct {
const hay = mem.trim(u8, haystack, " "); const hay = mem.trim(u8, haystack, " ");
const phrase = mem.trim(u8, act.phrase.resolve(b, step), " "); const phrase = mem.trim(u8, act.phrase.resolve(b, step), " ");
var candidate_vars: std.ArrayList(struct { name: []const u8, value: u64 }) = .init(b.allocator); var candidate_vars: std.array_list.Managed(struct { name: []const u8, value: u64 }) = .init(b.allocator);
var hay_it = mem.tokenizeScalar(u8, hay, ' '); var hay_it = mem.tokenizeScalar(u8, hay, ' ');
var needle_it = mem.tokenizeScalar(u8, phrase, ' '); var needle_it = mem.tokenizeScalar(u8, phrase, ' ');
@ -157,8 +157,8 @@ const Action = struct {
fn computeCmp(act: Action, b: *std.Build, step: *Step, global_vars: anytype) !bool { fn computeCmp(act: Action, b: *std.Build, step: *Step, global_vars: anytype) !bool {
const gpa = step.owner.allocator; const gpa = step.owner.allocator;
const phrase = act.phrase.resolve(b, step); const phrase = act.phrase.resolve(b, step);
var op_stack = std.ArrayList(enum { add, sub, mod, mul }).init(gpa); var op_stack = std.array_list.Managed(enum { add, sub, mod, mul }).init(gpa);
var values = std.ArrayList(u64).init(gpa); var values = std.array_list.Managed(u64).init(gpa);
var it = mem.tokenizeScalar(u8, phrase, ' '); var it = mem.tokenizeScalar(u8, phrase, ' ');
while (it.next()) |next| { while (it.next()) |next| {
@ -242,15 +242,15 @@ const ComputeCompareExpected = struct {
const Check = struct { const Check = struct {
kind: Kind, kind: Kind,
payload: Payload, payload: Payload,
data: std.ArrayList(u8), data: std.array_list.Managed(u8),
actions: std.ArrayList(Action), actions: std.array_list.Managed(Action),
fn create(allocator: Allocator, kind: Kind) Check { fn create(allocator: Allocator, kind: Kind) Check {
return .{ return .{
.kind = kind, .kind = kind,
.payload = .{ .none = {} }, .payload = .{ .none = {} },
.data = std.ArrayList(u8).init(allocator), .data = std.array_list.Managed(u8).init(allocator),
.actions = std.ArrayList(Action).init(allocator), .actions = std.array_list.Managed(Action).init(allocator),
}; };
} }
@ -1214,7 +1214,7 @@ const MachODumper = struct {
} }
fn dumpRebaseInfo(ctx: ObjectContext, data: []const u8, writer: anytype) !void { fn dumpRebaseInfo(ctx: ObjectContext, data: []const u8, writer: anytype) !void {
var rebases = std.ArrayList(u64).init(ctx.gpa); var rebases = std.array_list.Managed(u64).init(ctx.gpa);
defer rebases.deinit(); defer rebases.deinit();
try ctx.parseRebaseInfo(data, &rebases); try ctx.parseRebaseInfo(data, &rebases);
mem.sort(u64, rebases.items, {}, std.sort.asc(u64)); mem.sort(u64, rebases.items, {}, std.sort.asc(u64));
@ -1223,7 +1223,7 @@ const MachODumper = struct {
} }
} }
fn parseRebaseInfo(ctx: ObjectContext, data: []const u8, rebases: *std.ArrayList(u64)) !void { fn parseRebaseInfo(ctx: ObjectContext, data: []const u8, rebases: *std.array_list.Managed(u64)) !void {
var stream = std.io.fixedBufferStream(data); var stream = std.io.fixedBufferStream(data);
var creader = std.io.countingReader(stream.reader()); var creader = std.io.countingReader(stream.reader());
const reader = creader.reader(); const reader = creader.reader();
@ -1313,7 +1313,7 @@ const MachODumper = struct {
}; };
fn dumpBindInfo(ctx: ObjectContext, data: []const u8, writer: anytype) !void { fn dumpBindInfo(ctx: ObjectContext, data: []const u8, writer: anytype) !void {
var bindings = std.ArrayList(Binding).init(ctx.gpa); var bindings = std.array_list.Managed(Binding).init(ctx.gpa);
defer { defer {
for (bindings.items) |*b| { for (bindings.items) |*b| {
b.deinit(ctx.gpa); b.deinit(ctx.gpa);
@ -1335,7 +1335,7 @@ const MachODumper = struct {
} }
} }
fn parseBindInfo(ctx: ObjectContext, data: []const u8, bindings: *std.ArrayList(Binding)) !void { fn parseBindInfo(ctx: ObjectContext, data: []const u8, bindings: *std.array_list.Managed(Binding)) !void {
var stream = std.io.fixedBufferStream(data); var stream = std.io.fixedBufferStream(data);
var creader = std.io.countingReader(stream.reader()); var creader = std.io.countingReader(stream.reader());
const reader = creader.reader(); const reader = creader.reader();
@ -1346,7 +1346,7 @@ const MachODumper = struct {
var offset: u64 = 0; var offset: u64 = 0;
var addend: i64 = 0; var addend: i64 = 0;
var name_buf = std.ArrayList(u8).init(ctx.gpa); var name_buf = std.array_list.Managed(u8).init(ctx.gpa);
defer name_buf.deinit(); defer name_buf.deinit();
while (true) { while (true) {
@ -1434,7 +1434,7 @@ const MachODumper = struct {
var arena = std.heap.ArenaAllocator.init(ctx.gpa); var arena = std.heap.ArenaAllocator.init(ctx.gpa);
defer arena.deinit(); defer arena.deinit();
var exports = std.ArrayList(Export).init(arena.allocator()); var exports = std.array_list.Managed(Export).init(arena.allocator());
var it = TrieIterator{ .data = data }; var it = TrieIterator{ .data = data };
try parseTrieNode(arena.allocator(), &it, "", &exports); try parseTrieNode(arena.allocator(), &it, "", &exports);
@ -1546,7 +1546,7 @@ const MachODumper = struct {
arena: Allocator, arena: Allocator,
it: *TrieIterator, it: *TrieIterator,
prefix: []const u8, prefix: []const u8,
exports: *std.ArrayList(Export), exports: *std.array_list.Managed(Export),
) !void { ) !void {
const size = try it.readUleb128(); const size = try it.readUleb128();
if (size > 0) { if (size > 0) {
@ -1621,7 +1621,7 @@ const MachODumper = struct {
var ctx = ObjectContext{ .gpa = gpa, .data = bytes, .header = hdr }; var ctx = ObjectContext{ .gpa = gpa, .data = bytes, .header = hdr };
try ctx.parse(); try ctx.parse();
var output = std.ArrayList(u8).init(gpa); var output = std.array_list.Managed(u8).init(gpa);
const writer = output.writer(); const writer = output.writer();
switch (check.kind) { switch (check.kind) {
@ -1787,7 +1787,7 @@ const ElfDumper = struct {
try ctx.objects.append(gpa, .{ .name = name, .off = stream.pos, .len = size }); try ctx.objects.append(gpa, .{ .name = name, .off = stream.pos, .len = size });
} }
var output = std.ArrayList(u8).init(gpa); var output = std.array_list.Managed(u8).init(gpa);
const writer = output.writer(); const writer = output.writer();
switch (check.kind) { switch (check.kind) {
@ -1848,7 +1848,7 @@ const ElfDumper = struct {
files.putAssumeCapacityNoClobber(object.off - @sizeOf(elf.ar_hdr), object.name); files.putAssumeCapacityNoClobber(object.off - @sizeOf(elf.ar_hdr), object.name);
} }
var symbols = std.AutoArrayHashMap(usize, std.ArrayList([]const u8)).init(ctx.gpa); var symbols = std.AutoArrayHashMap(usize, std.array_list.Managed([]const u8)).init(ctx.gpa);
defer { defer {
for (symbols.values()) |*value| { for (symbols.values()) |*value| {
value.deinit(); value.deinit();
@ -1859,7 +1859,7 @@ const ElfDumper = struct {
for (ctx.symtab.items) |entry| { for (ctx.symtab.items) |entry| {
const gop = try symbols.getOrPut(@intCast(entry.off)); const gop = try symbols.getOrPut(@intCast(entry.off));
if (!gop.found_existing) { if (!gop.found_existing) {
gop.value_ptr.* = std.ArrayList([]const u8).init(ctx.gpa); gop.value_ptr.* = std.array_list.Managed([]const u8).init(ctx.gpa);
} }
try gop.value_ptr.append(entry.name); try gop.value_ptr.append(entry.name);
} }
@ -1944,7 +1944,7 @@ const ElfDumper = struct {
else => {}, else => {},
}; };
var output = std.ArrayList(u8).init(gpa); var output = std.array_list.Managed(u8).init(gpa);
const writer = output.writer(); const writer = output.writer();
switch (check.kind) { switch (check.kind) {
@ -2398,7 +2398,7 @@ const WasmDumper = struct {
return error.UnsupportedWasmVersion; return error.UnsupportedWasmVersion;
} }
var output = std.ArrayList(u8).init(gpa); var output = std.array_list.Managed(u8).init(gpa);
defer output.deinit(); defer output.deinit();
parseAndDumpInner(step, check, bytes, &fbs, &output) catch |err| switch (err) { parseAndDumpInner(step, check, bytes, &fbs, &output) catch |err| switch (err) {
error.EndOfStream => try output.appendSlice("\n<UnexpectedEndOfStream>"), error.EndOfStream => try output.appendSlice("\n<UnexpectedEndOfStream>"),
@ -2412,7 +2412,7 @@ const WasmDumper = struct {
check: Check, check: Check,
bytes: []const u8, bytes: []const u8,
fbs: *std.io.FixedBufferStream([]const u8), fbs: *std.io.FixedBufferStream([]const u8),
output: *std.ArrayList(u8), output: *std.array_list.Managed(u8),
) !void { ) !void {
const reader = fbs.reader(); const reader = fbs.reader();
const writer = output.writer(); const writer = output.writer();

View File

@ -4,7 +4,6 @@ const mem = std.mem;
const fs = std.fs; const fs = std.fs;
const assert = std.debug.assert; const assert = std.debug.assert;
const panic = std.debug.panic; const panic = std.debug.panic;
const ArrayList = std.ArrayList;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const Sha256 = std.crypto.hash.sha2.Sha256; const Sha256 = std.crypto.hash.sha2.Sha256;
const Allocator = mem.Allocator; const Allocator = mem.Allocator;
@ -60,7 +59,7 @@ filters: []const []const u8,
test_runner: ?TestRunner, test_runner: ?TestRunner,
wasi_exec_model: ?std.builtin.WasiExecModel = null, wasi_exec_model: ?std.builtin.WasiExecModel = null,
installed_headers: ArrayList(HeaderInstallation), installed_headers: std.array_list.Managed(HeaderInstallation),
/// This step is used to create an include tree that dependent modules can add to their include /// This step is used to create an include tree that dependent modules can add to their include
/// search paths. Installed headers are copied to this step. /// search paths. Installed headers are copied to this step.
@ -421,7 +420,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
.out_lib_filename = undefined, .out_lib_filename = undefined,
.major_only_filename = null, .major_only_filename = null,
.name_only_filename = null, .name_only_filename = null,
.installed_headers = ArrayList(HeaderInstallation).init(owner.allocator), .installed_headers = std.array_list.Managed(HeaderInstallation).init(owner.allocator),
.zig_lib_dir = null, .zig_lib_dir = null,
.exec_cmd_args = null, .exec_cmd_args = null,
.filters = options.filters, .filters = options.filters,
@ -766,9 +765,9 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
else => return err, else => return err,
}; };
var zig_cflags = ArrayList([]const u8).init(b.allocator); var zig_cflags = std.array_list.Managed([]const u8).init(b.allocator);
defer zig_cflags.deinit(); defer zig_cflags.deinit();
var zig_libs = ArrayList([]const u8).init(b.allocator); var zig_libs = std.array_list.Managed([]const u8).init(b.allocator);
defer zig_libs.deinit(); defer zig_libs.deinit();
var arg_it = mem.tokenizeAny(u8, stdout, " \r\n\t"); var arg_it = mem.tokenizeAny(u8, stdout, " \r\n\t");
@ -1076,7 +1075,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
const b = step.owner; const b = step.owner;
const arena = b.allocator; const arena = b.allocator;
var zig_args = ArrayList([]const u8).init(arena); var zig_args = std.array_list.Managed([]const u8).init(arena);
defer zig_args.deinit(); defer zig_args.deinit();
try zig_args.append(b.graph.zig_exe); try zig_args.append(b.graph.zig_exe);
@ -1798,7 +1797,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
try b.cache_root.handle.makePath("args"); try b.cache_root.handle.makePath("args");
const args_to_escape = zig_args.items[2..]; const args_to_escape = zig_args.items[2..];
var escaped_args = try ArrayList([]const u8).initCapacity(arena, args_to_escape.len); var escaped_args = try std.array_list.Managed([]const u8).initCapacity(arena, args_to_escape.len);
arg_blk: for (args_to_escape) |arg| { arg_blk: for (args_to_escape) |arg| {
for (arg, 0..) |c, arg_idx| { for (arg, 0..) |c, arg_idx| {
if (c == '\\' or c == '"') { if (c == '\\' or c == '"') {
@ -1948,7 +1947,7 @@ pub fn doAtomicSymLinks(
fn execPkgConfigList(b: *std.Build, out_code: *u8) (PkgConfigError || RunError)![]const PkgConfigPkg { fn execPkgConfigList(b: *std.Build, out_code: *u8) (PkgConfigError || RunError)![]const PkgConfigPkg {
const pkg_config_exe = b.graph.env_map.get("PKG_CONFIG") orelse "pkg-config"; const pkg_config_exe = b.graph.env_map.get("PKG_CONFIG") orelse "pkg-config";
const stdout = try b.runAllowFail(&[_][]const u8{ pkg_config_exe, "--list-all" }, out_code, .Ignore); const stdout = try b.runAllowFail(&[_][]const u8{ pkg_config_exe, "--list-all" }, out_code, .Ignore);
var list = ArrayList(PkgConfigPkg).init(b.allocator); var list = std.array_list.Managed(PkgConfigPkg).init(b.allocator);
errdefer list.deinit(); errdefer list.deinit();
var line_it = mem.tokenizeAny(u8, stdout, "\r\n"); var line_it = mem.tokenizeAny(u8, stdout, "\r\n");
while (line_it.next()) |line| { while (line_it.next()) |line| {
@ -1985,7 +1984,7 @@ fn getPkgConfigList(b: *std.Build) ![]const PkgConfigPkg {
} }
} }
fn addFlag(args: *ArrayList([]const u8), comptime name: []const u8, opt: ?bool) !void { fn addFlag(args: *std.array_list.Managed([]const u8), comptime name: []const u8, opt: ?bool) !void {
const cond = opt orelse return; const cond = opt orelse return;
try args.ensureUnusedCapacity(1); try args.ensureUnusedCapacity(1);
if (cond) { if (cond) {

View File

@ -621,7 +621,7 @@ fn expand_variables_cmake(
contents: []const u8, contents: []const u8,
values: std.StringArrayHashMap(Value), values: std.StringArrayHashMap(Value),
) ![]const u8 { ) ![]const u8 {
var result: std.ArrayList(u8) = .init(allocator); var result: std.array_list.Managed(u8) = .init(allocator);
errdefer result.deinit(); errdefer result.deinit();
const valid_varname_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789/_.+-"; const valid_varname_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789/_.+-";
@ -633,7 +633,7 @@ fn expand_variables_cmake(
source: usize, source: usize,
target: usize, target: usize,
}; };
var var_stack: std.ArrayList(Position) = .init(allocator); var var_stack: std.array_list.Managed(Position) = .init(allocator);
defer var_stack.deinit(); defer var_stack.deinit();
loop: while (curr < contents.len) : (curr += 1) { loop: while (curr < contents.len) : (curr += 1) {
switch (contents[curr]) { switch (contents[curr]) {

View File

@ -182,7 +182,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
return step.fail("unable to make path {s}: {s}", .{ cache_path, @errorName(err) }); return step.fail("unable to make path {s}: {s}", .{ cache_path, @errorName(err) });
}; };
var argv = std.ArrayList([]const u8).init(b.allocator); var argv = std.array_list.Managed([]const u8).init(b.allocator);
try argv.appendSlice(&.{ b.graph.zig_exe, "objcopy" }); try argv.appendSlice(&.{ b.graph.zig_exe, "objcopy" });
if (objcopy.only_section) |only_section| { if (objcopy.only_section) |only_section| {

View File

@ -679,15 +679,15 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
const run: *Run = @fieldParentPtr("step", step); const run: *Run = @fieldParentPtr("step", step);
const has_side_effects = run.hasSideEffects(); const has_side_effects = run.hasSideEffects();
var argv_list = std.ArrayList([]const u8).init(arena); var argv_list = std.array_list.Managed([]const u8).init(arena);
var output_placeholders = std.ArrayList(IndexedOutput).init(arena); var output_placeholders = std.array_list.Managed(IndexedOutput).init(arena);
var man = b.graph.cache.obtain(); var man = b.graph.cache.obtain();
defer man.deinit(); defer man.deinit();
if (run.env_map) |env_map| { if (run.env_map) |env_map| {
const KV = struct { []const u8, []const u8 }; const KV = struct { []const u8, []const u8 };
var kv_pairs = try std.ArrayList(KV).initCapacity(arena, env_map.count()); var kv_pairs = try std.array_list.Managed(KV).initCapacity(arena, env_map.count());
var iter = env_map.iterator(); var iter = env_map.iterator();
while (iter.next()) |entry| { while (iter.next()) |entry| {
kv_pairs.appendAssumeCapacity(.{ entry.key_ptr.*, entry.value_ptr.* }); kv_pairs.appendAssumeCapacity(.{ entry.key_ptr.*, entry.value_ptr.* });
@ -1080,7 +1080,7 @@ fn runCommand(
else => false, else => false,
}; };
var interp_argv = std.ArrayList([]const u8).init(b.allocator); var interp_argv = std.array_list.Managed([]const u8).init(b.allocator);
defer interp_argv.deinit(); defer interp_argv.deinit();
var env_map = run.env_map orelse &b.graph.env_map; var env_map = run.env_map orelse &b.graph.env_map;

View File

@ -10,8 +10,8 @@ pub const base_id: Step.Id = .translate_c;
step: Step, step: Step,
source: std.Build.LazyPath, source: std.Build.LazyPath,
include_dirs: std.ArrayList(std.Build.Module.IncludeDir), include_dirs: std.array_list.Managed(std.Build.Module.IncludeDir),
c_macros: std.ArrayList([]const u8), c_macros: std.array_list.Managed([]const u8),
out_basename: []const u8, out_basename: []const u8,
target: std.Build.ResolvedTarget, target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode, optimize: std.builtin.OptimizeMode,
@ -38,8 +38,8 @@ pub fn create(owner: *std.Build, options: Options) *TranslateC {
.makeFn = make, .makeFn = make,
}), }),
.source = source, .source = source,
.include_dirs = std.ArrayList(std.Build.Module.IncludeDir).init(owner.allocator), .include_dirs = std.array_list.Managed(std.Build.Module.IncludeDir).init(owner.allocator),
.c_macros = std.ArrayList([]const u8).init(owner.allocator), .c_macros = std.array_list.Managed([]const u8).init(owner.allocator),
.out_basename = undefined, .out_basename = undefined,
.target = options.target, .target = options.target,
.optimize = options.optimize, .optimize = options.optimize,
@ -153,7 +153,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
const b = step.owner; const b = step.owner;
const translate_c: *TranslateC = @fieldParentPtr("step", step); const translate_c: *TranslateC = @fieldParentPtr("step", step);
var argv_list = std.ArrayList([]const u8).init(b.allocator); var argv_list = std.array_list.Managed([]const u8).init(b.allocator);
try argv_list.append(b.graph.zig_exe); try argv_list.append(b.graph.zig_exe);
try argv_list.append("translate-c"); try argv_list.append("translate-c");
if (translate_c.link_libc) { if (translate_c.link_libc) {

View File

@ -117,7 +117,7 @@ pub fn GenericReader(
pub inline fn readAllArrayList( pub inline fn readAllArrayList(
self: Self, self: Self,
array_list: *std.ArrayList(u8), array_list: *std.array_list.Managed(u8),
max_append_size: usize, max_append_size: usize,
) (error{StreamTooLong} || Allocator.Error || Error)!void { ) (error{StreamTooLong} || Allocator.Error || Error)!void {
return @errorCast(self.any().readAllArrayList(array_list, max_append_size)); return @errorCast(self.any().readAllArrayList(array_list, max_append_size));
@ -126,7 +126,7 @@ pub fn GenericReader(
pub inline fn readAllArrayListAligned( pub inline fn readAllArrayListAligned(
self: Self, self: Self,
comptime alignment: ?Alignment, comptime alignment: ?Alignment,
array_list: *std.ArrayListAligned(u8, alignment), array_list: *std.array_list.AlignedManaged(u8, alignment),
max_append_size: usize, max_append_size: usize,
) (error{StreamTooLong} || Allocator.Error || Error)!void { ) (error{StreamTooLong} || Allocator.Error || Error)!void {
return @errorCast(self.any().readAllArrayListAligned( return @errorCast(self.any().readAllArrayListAligned(
@ -146,7 +146,7 @@ pub fn GenericReader(
pub inline fn readUntilDelimiterArrayList( pub inline fn readUntilDelimiterArrayList(
self: Self, self: Self,
array_list: *std.ArrayList(u8), array_list: *std.array_list.Managed(u8),
delimiter: u8, delimiter: u8,
max_size: usize, max_size: usize,
) (NoEofError || Allocator.Error || error{StreamTooLong})!void { ) (NoEofError || Allocator.Error || error{StreamTooLong})!void {

View File

@ -39,14 +39,14 @@ pub fn readNoEof(self: Self, buf: []u8) anyerror!void {
if (amt_read < buf.len) return error.EndOfStream; if (amt_read < buf.len) return error.EndOfStream;
} }
/// Appends to the `std.ArrayList` contents by reading from the stream /// Appends to the `std.array_list.Managed` contents by reading from the stream
/// until end of stream is found. /// until end of stream is found.
/// If the number of bytes appended would exceed `max_append_size`, /// If the number of bytes appended would exceed `max_append_size`,
/// `error.StreamTooLong` is returned /// `error.StreamTooLong` is returned
/// and the `std.ArrayList` has exactly `max_append_size` bytes appended. /// and the `std.array_list.Managed` has exactly `max_append_size` bytes appended.
pub fn readAllArrayList( pub fn readAllArrayList(
self: Self, self: Self,
array_list: *std.ArrayList(u8), array_list: *std.array_list.Managed(u8),
max_append_size: usize, max_append_size: usize,
) anyerror!void { ) anyerror!void {
return self.readAllArrayListAligned(null, array_list, max_append_size); return self.readAllArrayListAligned(null, array_list, max_append_size);
@ -55,7 +55,7 @@ pub fn readAllArrayList(
pub fn readAllArrayListAligned( pub fn readAllArrayListAligned(
self: Self, self: Self,
comptime alignment: ?Alignment, comptime alignment: ?Alignment,
array_list: *std.ArrayListAligned(u8, alignment), array_list: *std.array_list.AlignedManaged(u8, alignment),
max_append_size: usize, max_append_size: usize,
) anyerror!void { ) anyerror!void {
try array_list.ensureTotalCapacity(@min(max_append_size, 4096)); try array_list.ensureTotalCapacity(@min(max_append_size, 4096));
@ -87,20 +87,20 @@ pub fn readAllArrayListAligned(
/// Caller owns returned memory. /// Caller owns returned memory.
/// If this function returns an error, the contents from the stream read so far are lost. /// If this function returns an error, the contents from the stream read so far are lost.
pub fn readAllAlloc(self: Self, allocator: mem.Allocator, max_size: usize) anyerror![]u8 { pub fn readAllAlloc(self: Self, allocator: mem.Allocator, max_size: usize) anyerror![]u8 {
var array_list = std.ArrayList(u8).init(allocator); var array_list = std.array_list.Managed(u8).init(allocator);
defer array_list.deinit(); defer array_list.deinit();
try self.readAllArrayList(&array_list, max_size); try self.readAllArrayList(&array_list, max_size);
return try array_list.toOwnedSlice(); return try array_list.toOwnedSlice();
} }
/// Deprecated: use `streamUntilDelimiter` with ArrayList's writer instead. /// Deprecated: use `streamUntilDelimiter` with ArrayList's writer instead.
/// Replaces the `std.ArrayList` contents by reading from the stream until `delimiter` is found. /// Replaces the `std.array_list.Managed` contents by reading from the stream until `delimiter` is found.
/// Does not include the delimiter in the result. /// Does not include the delimiter in the result.
/// If the `std.ArrayList` length would exceed `max_size`, `error.StreamTooLong` is returned and the /// If the `std.array_list.Managed` length would exceed `max_size`, `error.StreamTooLong` is returned and the
/// `std.ArrayList` is populated with `max_size` bytes from the stream. /// `std.array_list.Managed` is populated with `max_size` bytes from the stream.
pub fn readUntilDelimiterArrayList( pub fn readUntilDelimiterArrayList(
self: Self, self: Self,
array_list: *std.ArrayList(u8), array_list: *std.array_list.Managed(u8),
delimiter: u8, delimiter: u8,
max_size: usize, max_size: usize,
) anyerror!void { ) anyerror!void {
@ -119,7 +119,7 @@ pub fn readUntilDelimiterAlloc(
delimiter: u8, delimiter: u8,
max_size: usize, max_size: usize,
) anyerror![]u8 { ) anyerror![]u8 {
var array_list = std.ArrayList(u8).init(allocator); var array_list = std.array_list.Managed(u8).init(allocator);
defer array_list.deinit(); defer array_list.deinit();
try self.streamUntilDelimiter(array_list.writer(), delimiter, max_size); try self.streamUntilDelimiter(array_list.writer(), delimiter, max_size);
return try array_list.toOwnedSlice(); return try array_list.toOwnedSlice();
@ -154,7 +154,7 @@ pub fn readUntilDelimiterOrEofAlloc(
delimiter: u8, delimiter: u8,
max_size: usize, max_size: usize,
) anyerror!?[]u8 { ) anyerror!?[]u8 {
var array_list = std.ArrayList(u8).init(allocator); var array_list = std.array_list.Managed(u8).init(allocator);
defer array_list.deinit(); defer array_list.deinit();
self.streamUntilDelimiter(array_list.writer(), delimiter, max_size) catch |err| switch (err) { self.streamUntilDelimiter(array_list.writer(), delimiter, max_size) catch |err| switch (err) {
error.EndOfStream => if (array_list.items.len == 0) { error.EndOfStream => if (array_list.items.len == 0) {

View File

@ -34,7 +34,7 @@ test "skipBytes" {
test "readUntilDelimiterArrayList returns ArrayLists with bytes read until the delimiter, then EndOfStream" { test "readUntilDelimiterArrayList returns ArrayLists with bytes read until the delimiter, then EndOfStream" {
const a = std.testing.allocator; const a = std.testing.allocator;
var list = std.ArrayList(u8).init(a); var list = std.array_list.Managed(u8).init(a);
defer list.deinit(); defer list.deinit();
var fis = std.io.fixedBufferStream("0000\n1234\n"); var fis = std.io.fixedBufferStream("0000\n1234\n");
@ -49,7 +49,7 @@ test "readUntilDelimiterArrayList returns ArrayLists with bytes read until the d
test "readUntilDelimiterArrayList returns an empty ArrayList" { test "readUntilDelimiterArrayList returns an empty ArrayList" {
const a = std.testing.allocator; const a = std.testing.allocator;
var list = std.ArrayList(u8).init(a); var list = std.array_list.Managed(u8).init(a);
defer list.deinit(); defer list.deinit();
var fis = std.io.fixedBufferStream("\n"); var fis = std.io.fixedBufferStream("\n");
@ -61,7 +61,7 @@ test "readUntilDelimiterArrayList returns an empty ArrayList" {
test "readUntilDelimiterArrayList returns StreamTooLong, then an ArrayList with bytes read until the delimiter" { test "readUntilDelimiterArrayList returns StreamTooLong, then an ArrayList with bytes read until the delimiter" {
const a = std.testing.allocator; const a = std.testing.allocator;
var list = std.ArrayList(u8).init(a); var list = std.array_list.Managed(u8).init(a);
defer list.deinit(); defer list.deinit();
var fis = std.io.fixedBufferStream("1234567\n"); var fis = std.io.fixedBufferStream("1234567\n");
@ -75,7 +75,7 @@ test "readUntilDelimiterArrayList returns StreamTooLong, then an ArrayList with
test "readUntilDelimiterArrayList returns EndOfStream" { test "readUntilDelimiterArrayList returns EndOfStream" {
const a = std.testing.allocator; const a = std.testing.allocator;
var list = std.ArrayList(u8).init(a); var list = std.array_list.Managed(u8).init(a);
defer list.deinit(); defer list.deinit();
var fis = std.io.fixedBufferStream("1234"); var fis = std.io.fixedBufferStream("1234");

View File

@ -3,6 +3,15 @@
//! provide meaningful and unsurprising defaults. This struct does reference //! provide meaningful and unsurprising defaults. This struct does reference
//! any resources and it is copyable. //! any resources and it is copyable.
const Query = @This();
const std = @import("../std.zig");
const builtin = @import("builtin");
const assert = std.debug.assert;
const Target = std.Target;
const mem = std.mem;
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
/// `null` means native. /// `null` means native.
cpu_arch: ?Target.Cpu.Arch = null, cpu_arch: ?Target.Cpu.Arch = null,
@ -394,7 +403,7 @@ pub fn canDetectLibC(self: Query) bool {
/// Formats a version with the patch component omitted if it is zero, /// Formats a version with the patch component omitted if it is zero,
/// unlike SemanticVersion.format which formats all its version components regardless. /// unlike SemanticVersion.format which formats all its version components regardless.
fn formatVersion(version: SemanticVersion, gpa: Allocator, list: *std.ArrayListUnmanaged(u8)) !void { fn formatVersion(version: SemanticVersion, gpa: Allocator, list: *ArrayList(u8)) !void {
if (version.patch == 0) { if (version.patch == 0) {
try list.print(gpa, "{d}.{d}", .{ version.major, version.minor }); try list.print(gpa, "{d}.{d}", .{ version.major, version.minor });
} else { } else {
@ -408,7 +417,7 @@ pub fn zigTriple(self: Query, gpa: Allocator) Allocator.Error![]u8 {
const arch_name = if (self.cpu_arch) |arch| @tagName(arch) else "native"; const arch_name = if (self.cpu_arch) |arch| @tagName(arch) else "native";
const os_name = if (self.os_tag) |os_tag| @tagName(os_tag) else "native"; const os_name = if (self.os_tag) |os_tag| @tagName(os_tag) else "native";
var result: std.ArrayListUnmanaged(u8) = .empty; var result: ArrayList(u8) = .empty;
defer result.deinit(gpa); defer result.deinit(gpa);
try result.print(gpa, "{s}-{s}", .{ arch_name, os_name }); try result.print(gpa, "{s}-{s}", .{ arch_name, os_name });
@ -469,7 +478,7 @@ pub fn zigTriple(self: Query, gpa: Allocator) Allocator.Error![]u8 {
/// Renders the query into a textual representation that can be parsed via the /// Renders the query into a textual representation that can be parsed via the
/// `-mcpu` flag passed to the Zig compiler. /// `-mcpu` flag passed to the Zig compiler.
/// Appends the result to `buffer`. /// Appends the result to `buffer`.
pub fn serializeCpu(q: Query, buffer: *std.ArrayList(u8)) Allocator.Error!void { pub fn serializeCpu(q: Query, buffer: *std.array_list.Managed(u8)) Allocator.Error!void {
try buffer.ensureUnusedCapacity(8); try buffer.ensureUnusedCapacity(8);
switch (q.cpu_model) { switch (q.cpu_model) {
.native => { .native => {
@ -512,7 +521,7 @@ pub fn serializeCpu(q: Query, buffer: *std.ArrayList(u8)) Allocator.Error!void {
} }
pub fn serializeCpuAlloc(q: Query, ally: Allocator) Allocator.Error![]u8 { pub fn serializeCpuAlloc(q: Query, ally: Allocator) Allocator.Error![]u8 {
var buffer = std.ArrayList(u8).init(ally); var buffer = std.array_list.Managed(u8).init(ally);
try serializeCpu(q, &buffer); try serializeCpu(q, &buffer);
return buffer.toOwnedSlice(); return buffer.toOwnedSlice();
} }
@ -596,14 +605,6 @@ fn versionEqualOpt(a: ?SemanticVersion, b: ?SemanticVersion) bool {
return SemanticVersion.order(a.?, b.?) == .eq; return SemanticVersion.order(a.?, b.?) == .eq;
} }
const Query = @This();
const std = @import("../std.zig");
const builtin = @import("builtin");
const assert = std.debug.assert;
const Target = std.Target;
const mem = std.mem;
const Allocator = std.mem.Allocator;
test parse { test parse {
if (builtin.target.isGnuLibC()) { if (builtin.target.isGnuLibC()) {
var query = try Query.parse(.{}); var query = try Query.parse(.{});

View File

@ -5,27 +5,18 @@ const testing = std.testing;
const mem = std.mem; const mem = std.mem;
const math = std.math; const math = std.math;
const Allocator = mem.Allocator; const Allocator = mem.Allocator;
const ArrayList = std.ArrayList;
/// A contiguous, growable list of items in memory. /// Deprecated.
/// This is a wrapper around an array of T values. Initialize with `init`. pub fn Managed(comptime T: type) type {
/// return AlignedManaged(T, null);
/// This struct internally stores a `std.mem.Allocator` for memory management.
/// To manually specify an allocator with each function call see `ArrayListUnmanaged`.
pub fn ArrayList(comptime T: type) type {
return ArrayListAligned(T, null);
} }
/// A contiguous, growable list of arbitrarily aligned items in memory. /// Deprecated.
/// This is a wrapper around an array of T values aligned to `alignment`-byte pub fn AlignedManaged(comptime T: type, comptime alignment: ?mem.Alignment) type {
/// addresses. If the specified alignment is `null`, then `@alignOf(T)` is used.
/// Initialize with `init`.
///
/// This struct internally stores a `std.mem.Allocator` for memory management.
/// To manually specify an allocator with each function call see `ArrayListAlignedUnmanaged`.
pub fn ArrayListAligned(comptime T: type, comptime alignment: ?mem.Alignment) type {
if (alignment) |a| { if (alignment) |a| {
if (a.toByteUnits() == @alignOf(T)) { if (a.toByteUnits() == @alignOf(T)) {
return ArrayListAligned(T, null); return AlignedManaged(T, null);
} }
} }
return struct { return struct {
@ -96,11 +87,11 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?mem.Alignment) ty
}; };
} }
/// Initializes an ArrayListUnmanaged with the `items` and `capacity` fields /// Initializes an ArrayList with the `items` and `capacity` fields
/// of this ArrayList. Empties this ArrayList. /// of this ArrayList. Empties this ArrayList.
pub fn moveToUnmanaged(self: *Self) ArrayListAlignedUnmanaged(T, alignment) { pub fn moveToUnmanaged(self: *Self) Aligned(T, alignment) {
const allocator = self.allocator; const allocator = self.allocator;
const result: ArrayListAlignedUnmanaged(T, alignment) = .{ .items = self.items, .capacity = self.capacity }; const result: Aligned(T, alignment) = .{ .items = self.items, .capacity = self.capacity };
self.* = init(allocator); self.* = init(allocator);
return result; return result;
} }
@ -181,7 +172,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?mem.Alignment) ty
// a new buffer and doing our own copy. With a realloc() call, // a new buffer and doing our own copy. With a realloc() call,
// the allocator implementation would pointlessly copy our // the allocator implementation would pointlessly copy our
// extra capacity. // extra capacity.
const new_capacity = ArrayListAlignedUnmanaged(T, alignment).growCapacity(self.capacity, new_len); const new_capacity = Aligned(T, alignment).growCapacity(self.capacity, new_len);
const old_memory = self.allocatedSlice(); const old_memory = self.allocatedSlice();
if (self.allocator.remap(old_memory, new_capacity)) |new_memory| { if (self.allocator.remap(old_memory, new_capacity)) |new_memory| {
self.items.ptr = new_memory.ptr; self.items.ptr = new_memory.ptr;
@ -449,7 +440,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?mem.Alignment) ty
if (self.capacity >= new_capacity) return; if (self.capacity >= new_capacity) return;
const better_capacity = ArrayListAlignedUnmanaged(T, alignment).growCapacity(self.capacity, new_capacity); const better_capacity = Aligned(T, alignment).growCapacity(self.capacity, new_capacity);
return self.ensureTotalCapacityPrecise(better_capacity); return self.ensureTotalCapacityPrecise(better_capacity);
} }
@ -597,14 +588,6 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?mem.Alignment) ty
}; };
} }
/// An ArrayList, but the allocator is passed as a parameter to the relevant functions
/// rather than stored in the struct itself. The same allocator must be used throughout
/// the entire lifetime of an ArrayListUnmanaged. Initialize directly or with
/// `initCapacity`, and deinitialize with `deinit` or use `toOwnedSlice`.
pub fn ArrayListUnmanaged(comptime T: type) type {
return ArrayListAlignedUnmanaged(T, null);
}
/// A contiguous, growable list of arbitrarily aligned items in memory. /// A contiguous, growable list of arbitrarily aligned items in memory.
/// This is a wrapper around an array of T values aligned to `alignment`-byte /// This is a wrapper around an array of T values aligned to `alignment`-byte
/// addresses. If the specified alignment is `null`, then `@alignOf(T)` is used. /// addresses. If the specified alignment is `null`, then `@alignOf(T)` is used.
@ -614,10 +597,10 @@ pub fn ArrayListUnmanaged(comptime T: type) type {
/// or use `toOwnedSlice`. /// or use `toOwnedSlice`.
/// ///
/// Default initialization of this struct is deprecated; use `.empty` instead. /// Default initialization of this struct is deprecated; use `.empty` instead.
pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?mem.Alignment) type { pub fn Aligned(comptime T: type, comptime alignment: ?mem.Alignment) type {
if (alignment) |a| { if (alignment) |a| {
if (a.toByteUnits() == @alignOf(T)) { if (a.toByteUnits() == @alignOf(T)) {
return ArrayListAlignedUnmanaged(T, null); return Aligned(T, null);
} }
} }
return struct { return struct {
@ -675,11 +658,11 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?mem.Alig
/// Convert this list into an analogous memory-managed one. /// Convert this list into an analogous memory-managed one.
/// The returned list has ownership of the underlying memory. /// The returned list has ownership of the underlying memory.
pub fn toManaged(self: *Self, gpa: Allocator) ArrayListAligned(T, alignment) { pub fn toManaged(self: *Self, gpa: Allocator) AlignedManaged(T, alignment) {
return .{ .items = self.items, .capacity = self.capacity, .allocator = gpa }; return .{ .items = self.items, .capacity = self.capacity, .allocator = gpa };
} }
/// ArrayListUnmanaged takes ownership of the passed in slice. /// ArrayList takes ownership of the passed in slice.
/// Deinitialize with `deinit` or use `toOwnedSlice`. /// Deinitialize with `deinit` or use `toOwnedSlice`.
pub fn fromOwnedSlice(slice: Slice) Self { pub fn fromOwnedSlice(slice: Slice) Self {
return Self{ return Self{
@ -688,7 +671,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?mem.Alig
}; };
} }
/// ArrayListUnmanaged takes ownership of the passed in slice. /// ArrayList takes ownership of the passed in slice.
/// Deinitialize with `deinit` or use `toOwnedSlice`. /// Deinitialize with `deinit` or use `toOwnedSlice`.
pub fn fromOwnedSliceSentinel(comptime sentinel: T, slice: [:sentinel]T) Self { pub fn fromOwnedSliceSentinel(comptime sentinel: T, slice: [:sentinel]T) Self {
return Self{ return Self{
@ -1444,7 +1427,7 @@ fn addOrOom(a: usize, b: usize) error{OutOfMemory}!usize {
test "init" { test "init" {
{ {
var list = ArrayList(i32).init(testing.allocator); var list = Managed(i32).init(testing.allocator);
defer list.deinit(); defer list.deinit();
try testing.expect(list.items.len == 0); try testing.expect(list.items.len == 0);
@ -1452,7 +1435,7 @@ test "init" {
} }
{ {
const list: ArrayListUnmanaged(i32) = .empty; const list: ArrayList(i32) = .empty;
try testing.expect(list.items.len == 0); try testing.expect(list.items.len == 0);
try testing.expect(list.capacity == 0); try testing.expect(list.capacity == 0);
@ -1462,13 +1445,13 @@ test "init" {
test "initCapacity" { test "initCapacity" {
const a = testing.allocator; const a = testing.allocator;
{ {
var list = try ArrayList(i8).initCapacity(a, 200); var list = try Managed(i8).initCapacity(a, 200);
defer list.deinit(); defer list.deinit();
try testing.expect(list.items.len == 0); try testing.expect(list.items.len == 0);
try testing.expect(list.capacity >= 200); try testing.expect(list.capacity >= 200);
} }
{ {
var list = try ArrayListUnmanaged(i8).initCapacity(a, 200); var list = try ArrayList(i8).initCapacity(a, 200);
defer list.deinit(a); defer list.deinit(a);
try testing.expect(list.items.len == 0); try testing.expect(list.items.len == 0);
try testing.expect(list.capacity >= 200); try testing.expect(list.capacity >= 200);
@ -1478,7 +1461,7 @@ test "initCapacity" {
test "clone" { test "clone" {
const a = testing.allocator; const a = testing.allocator;
{ {
var array = ArrayList(i32).init(a); var array = Managed(i32).init(a);
try array.append(-1); try array.append(-1);
try array.append(3); try array.append(3);
try array.append(5); try array.append(5);
@ -1497,7 +1480,7 @@ test "clone" {
try testing.expectEqual(@as(i32, 5), cloned.items[2]); try testing.expectEqual(@as(i32, 5), cloned.items[2]);
} }
{ {
var array: ArrayListUnmanaged(i32) = .empty; var array: ArrayList(i32) = .empty;
try array.append(a, -1); try array.append(a, -1);
try array.append(a, 3); try array.append(a, 3);
try array.append(a, 5); try array.append(a, 5);
@ -1519,7 +1502,7 @@ test "clone" {
test "basic" { test "basic" {
const a = testing.allocator; const a = testing.allocator;
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
{ {
@ -1569,7 +1552,7 @@ test "basic" {
try testing.expect(list.pop() == 33); try testing.expect(list.pop() == 33);
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
{ {
@ -1623,7 +1606,7 @@ test "basic" {
test "appendNTimes" { test "appendNTimes" {
const a = testing.allocator; const a = testing.allocator;
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.appendNTimes(2, 10); try list.appendNTimes(2, 10);
@ -1633,7 +1616,7 @@ test "appendNTimes" {
} }
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.appendNTimes(a, 2, 10); try list.appendNTimes(a, 2, 10);
@ -1647,12 +1630,12 @@ test "appendNTimes" {
test "appendNTimes with failing allocator" { test "appendNTimes with failing allocator" {
const a = testing.failing_allocator; const a = testing.failing_allocator;
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try testing.expectError(error.OutOfMemory, list.appendNTimes(2, 10)); try testing.expectError(error.OutOfMemory, list.appendNTimes(2, 10));
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try testing.expectError(error.OutOfMemory, list.appendNTimes(a, 2, 10)); try testing.expectError(error.OutOfMemory, list.appendNTimes(a, 2, 10));
} }
@ -1661,7 +1644,7 @@ test "appendNTimes with failing allocator" {
test "orderedRemove" { test "orderedRemove" {
const a = testing.allocator; const a = testing.allocator;
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.append(1); try list.append(1);
@ -1687,7 +1670,7 @@ test "orderedRemove" {
try testing.expectEqual(@as(usize, 4), list.items.len); try testing.expectEqual(@as(usize, 4), list.items.len);
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.append(a, 1); try list.append(a, 1);
@ -1714,7 +1697,7 @@ test "orderedRemove" {
} }
{ {
// remove last item // remove last item
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.append(1); try list.append(1);
try testing.expectEqual(@as(i32, 1), list.orderedRemove(0)); try testing.expectEqual(@as(i32, 1), list.orderedRemove(0));
@ -1722,7 +1705,7 @@ test "orderedRemove" {
} }
{ {
// remove last item // remove last item
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.append(a, 1); try list.append(a, 1);
try testing.expectEqual(@as(i32, 1), list.orderedRemove(0)); try testing.expectEqual(@as(i32, 1), list.orderedRemove(0));
@ -1733,7 +1716,7 @@ test "orderedRemove" {
test "swapRemove" { test "swapRemove" {
const a = testing.allocator; const a = testing.allocator;
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.append(1); try list.append(1);
@ -1759,7 +1742,7 @@ test "swapRemove" {
try testing.expect(list.items.len == 4); try testing.expect(list.items.len == 4);
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.append(a, 1); try list.append(a, 1);
@ -1789,7 +1772,7 @@ test "swapRemove" {
test "insert" { test "insert" {
const a = testing.allocator; const a = testing.allocator;
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.insert(0, 1); try list.insert(0, 1);
@ -1802,7 +1785,7 @@ test "insert" {
try testing.expect(list.items[3] == 3); try testing.expect(list.items[3] == 3);
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.insert(a, 0, 1); try list.insert(a, 0, 1);
@ -1819,7 +1802,7 @@ test "insert" {
test "insertSlice" { test "insertSlice" {
const a = testing.allocator; const a = testing.allocator;
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.append(1); try list.append(1);
@ -1840,7 +1823,7 @@ test "insertSlice" {
try testing.expect(list.items[0] == 1); try testing.expect(list.items[0] == 1);
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.append(a, 1); try list.append(a, 1);
@ -1862,11 +1845,11 @@ test "insertSlice" {
} }
} }
test "ArrayList.replaceRange" { test "Managed.replaceRange" {
const a = testing.allocator; const a = testing.allocator;
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 });
@ -1875,7 +1858,7 @@ test "ArrayList.replaceRange" {
try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 2, 3, 4, 5 }, list.items); try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 2, 3, 4, 5 }, list.items);
} }
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 });
@ -1888,7 +1871,7 @@ test "ArrayList.replaceRange" {
); );
} }
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 });
@ -1897,7 +1880,7 @@ test "ArrayList.replaceRange" {
try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 4, 5 }, list.items); try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 4, 5 }, list.items);
} }
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 });
@ -1906,7 +1889,7 @@ test "ArrayList.replaceRange" {
try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 5 }, list.items); try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 5 }, list.items);
} }
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 });
@ -1916,11 +1899,11 @@ test "ArrayList.replaceRange" {
} }
} }
test "ArrayList.replaceRangeAssumeCapacity" { test "Managed.replaceRangeAssumeCapacity" {
const a = testing.allocator; const a = testing.allocator;
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 });
@ -1929,7 +1912,7 @@ test "ArrayList.replaceRangeAssumeCapacity" {
try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 2, 3, 4, 5 }, list.items); try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 2, 3, 4, 5 }, list.items);
} }
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 });
@ -1942,7 +1925,7 @@ test "ArrayList.replaceRangeAssumeCapacity" {
); );
} }
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 });
@ -1951,7 +1934,7 @@ test "ArrayList.replaceRangeAssumeCapacity" {
try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 4, 5 }, list.items); try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 4, 5 }, list.items);
} }
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 });
@ -1960,7 +1943,7 @@ test "ArrayList.replaceRangeAssumeCapacity" {
try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 5 }, list.items); try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 5 }, list.items);
} }
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(&[_]i32{ 1, 2, 3, 4, 5 });
@ -1970,11 +1953,11 @@ test "ArrayList.replaceRangeAssumeCapacity" {
} }
} }
test "ArrayListUnmanaged.replaceRange" { test "ArrayList.replaceRange" {
const a = testing.allocator; const a = testing.allocator;
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 });
@ -1983,7 +1966,7 @@ test "ArrayListUnmanaged.replaceRange" {
try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 2, 3, 4, 5 }, list.items); try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 2, 3, 4, 5 }, list.items);
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 });
@ -1996,7 +1979,7 @@ test "ArrayListUnmanaged.replaceRange" {
); );
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 });
@ -2005,7 +1988,7 @@ test "ArrayListUnmanaged.replaceRange" {
try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 4, 5 }, list.items); try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 4, 5 }, list.items);
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 });
@ -2014,7 +1997,7 @@ test "ArrayListUnmanaged.replaceRange" {
try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 5 }, list.items); try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 5 }, list.items);
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 });
@ -2024,11 +2007,11 @@ test "ArrayListUnmanaged.replaceRange" {
} }
} }
test "ArrayListUnmanaged.replaceRangeAssumeCapacity" { test "ArrayList.replaceRangeAssumeCapacity" {
const a = testing.allocator; const a = testing.allocator;
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 });
@ -2037,7 +2020,7 @@ test "ArrayListUnmanaged.replaceRangeAssumeCapacity" {
try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 2, 3, 4, 5 }, list.items); try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 2, 3, 4, 5 }, list.items);
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 });
@ -2050,7 +2033,7 @@ test "ArrayListUnmanaged.replaceRangeAssumeCapacity" {
); );
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 });
@ -2059,7 +2042,7 @@ test "ArrayListUnmanaged.replaceRangeAssumeCapacity" {
try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 4, 5 }, list.items); try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 4, 5 }, list.items);
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 });
@ -2068,7 +2051,7 @@ test "ArrayListUnmanaged.replaceRangeAssumeCapacity" {
try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 5 }, list.items); try testing.expectEqualSlices(i32, &[_]i32{ 1, 0, 0, 0, 5 }, list.items);
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 }); try list.appendSlice(a, &[_]i32{ 1, 2, 3, 4, 5 });
@ -2080,15 +2063,15 @@ test "ArrayListUnmanaged.replaceRangeAssumeCapacity" {
const Item = struct { const Item = struct {
integer: i32, integer: i32,
sub_items: ArrayList(Item), sub_items: Managed(Item),
}; };
const ItemUnmanaged = struct { const ItemUnmanaged = struct {
integer: i32, integer: i32,
sub_items: ArrayListUnmanaged(ItemUnmanaged), sub_items: ArrayList(ItemUnmanaged),
}; };
test "ArrayList(T) of struct T" { test "Managed(T) of struct T" {
const a = std.testing.allocator; const a = std.testing.allocator;
{ {
var root = Item{ .integer = 1, .sub_items = .init(a) }; var root = Item{ .integer = 1, .sub_items = .init(a) };
@ -2104,11 +2087,11 @@ test "ArrayList(T) of struct T" {
} }
} }
test "ArrayList(u8) implements writer" { test "Managed(u8) implements writer" {
const a = testing.allocator; const a = testing.allocator;
{ {
var buffer = ArrayList(u8).init(a); var buffer = Managed(u8).init(a);
defer buffer.deinit(); defer buffer.deinit();
const x: i32 = 42; const x: i32 = 42;
@ -2118,7 +2101,7 @@ test "ArrayList(u8) implements writer" {
try testing.expectEqualSlices(u8, "x: 42\ny: 1234\n", buffer.items); try testing.expectEqualSlices(u8, "x: 42\ny: 1234\n", buffer.items);
} }
{ {
var list = ArrayListAligned(u8, .@"2").init(a); var list = AlignedManaged(u8, .@"2").init(a);
defer list.deinit(); defer list.deinit();
const writer = list.writer(); const writer = list.writer();
@ -2131,11 +2114,11 @@ test "ArrayList(u8) implements writer" {
} }
} }
test "ArrayListUnmanaged(u8) implements writer" { test "ArrayList(u8) implements writer" {
const a = testing.allocator; const a = testing.allocator;
{ {
var buffer: ArrayListUnmanaged(u8) = .empty; var buffer: ArrayList(u8) = .empty;
defer buffer.deinit(a); defer buffer.deinit(a);
const x: i32 = 42; const x: i32 = 42;
@ -2145,7 +2128,7 @@ test "ArrayListUnmanaged(u8) implements writer" {
try testing.expectEqualSlices(u8, "x: 42\ny: 1234\n", buffer.items); try testing.expectEqualSlices(u8, "x: 42\ny: 1234\n", buffer.items);
} }
{ {
var list: ArrayListAlignedUnmanaged(u8, .@"2") = .empty; var list: Aligned(u8, .@"2") = .empty;
defer list.deinit(a); defer list.deinit(a);
const writer = list.writer(a); const writer = list.writer(a);
@ -2163,7 +2146,7 @@ test "shrink still sets length when resizing is disabled" {
const a = failing_allocator.allocator(); const a = failing_allocator.allocator();
{ {
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.append(1); try list.append(1);
@ -2174,7 +2157,7 @@ test "shrink still sets length when resizing is disabled" {
try testing.expect(list.items.len == 1); try testing.expect(list.items.len == 1);
} }
{ {
var list: ArrayListUnmanaged(i32) = .empty; var list: ArrayList(i32) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.append(a, 1); try list.append(a, 1);
@ -2190,7 +2173,7 @@ test "shrinkAndFree with a copy" {
var failing_allocator = testing.FailingAllocator.init(testing.allocator, .{ .resize_fail_index = 0 }); var failing_allocator = testing.FailingAllocator.init(testing.allocator, .{ .resize_fail_index = 0 });
const a = failing_allocator.allocator(); const a = failing_allocator.allocator();
var list = ArrayList(i32).init(a); var list = Managed(i32).init(a);
defer list.deinit(); defer list.deinit();
try list.appendNTimes(3, 16); try list.appendNTimes(3, 16);
@ -2201,7 +2184,7 @@ test "shrinkAndFree with a copy" {
test "addManyAsArray" { test "addManyAsArray" {
const a = std.testing.allocator; const a = std.testing.allocator;
{ {
var list = ArrayList(u8).init(a); var list = Managed(u8).init(a);
defer list.deinit(); defer list.deinit();
(try list.addManyAsArray(4)).* = "aoeu".*; (try list.addManyAsArray(4)).* = "aoeu".*;
@ -2211,7 +2194,7 @@ test "addManyAsArray" {
try testing.expectEqualSlices(u8, list.items, "aoeuasdf"); try testing.expectEqualSlices(u8, list.items, "aoeuasdf");
} }
{ {
var list: ArrayListUnmanaged(u8) = .empty; var list: ArrayList(u8) = .empty;
defer list.deinit(a); defer list.deinit(a);
(try list.addManyAsArray(a, 4)).* = "aoeu".*; (try list.addManyAsArray(a, 4)).* = "aoeu".*;
@ -2227,7 +2210,7 @@ test "growing memory preserves contents" {
// will be triggered in the next operation. // will be triggered in the next operation.
const a = std.testing.allocator; const a = std.testing.allocator;
{ {
var list = ArrayList(u8).init(a); var list = Managed(u8).init(a);
defer list.deinit(); defer list.deinit();
(try list.addManyAsArray(4)).* = "abcd".*; (try list.addManyAsArray(4)).* = "abcd".*;
@ -2241,7 +2224,7 @@ test "growing memory preserves contents" {
try testing.expectEqualSlices(u8, list.items, "abcdijklefgh"); try testing.expectEqualSlices(u8, list.items, "abcdijklefgh");
} }
{ {
var list: ArrayListUnmanaged(u8) = .empty; var list: ArrayList(u8) = .empty;
defer list.deinit(a); defer list.deinit(a);
(try list.addManyAsArray(a, 4)).* = "abcd".*; (try list.addManyAsArray(a, 4)).* = "abcd".*;
@ -2259,22 +2242,22 @@ test "growing memory preserves contents" {
test "fromOwnedSlice" { test "fromOwnedSlice" {
const a = testing.allocator; const a = testing.allocator;
{ {
var orig_list = ArrayList(u8).init(a); var orig_list = Managed(u8).init(a);
defer orig_list.deinit(); defer orig_list.deinit();
try orig_list.appendSlice("foobar"); try orig_list.appendSlice("foobar");
const slice = try orig_list.toOwnedSlice(); const slice = try orig_list.toOwnedSlice();
var list = ArrayList(u8).fromOwnedSlice(a, slice); var list = Managed(u8).fromOwnedSlice(a, slice);
defer list.deinit(); defer list.deinit();
try testing.expectEqualStrings(list.items, "foobar"); try testing.expectEqualStrings(list.items, "foobar");
} }
{ {
var list = ArrayList(u8).init(a); var list = Managed(u8).init(a);
defer list.deinit(); defer list.deinit();
try list.appendSlice("foobar"); try list.appendSlice("foobar");
const slice = try list.toOwnedSlice(); const slice = try list.toOwnedSlice();
var unmanaged = ArrayListUnmanaged(u8).fromOwnedSlice(slice); var unmanaged = ArrayList(u8).fromOwnedSlice(slice);
defer unmanaged.deinit(a); defer unmanaged.deinit(a);
try testing.expectEqualStrings(unmanaged.items, "foobar"); try testing.expectEqualStrings(unmanaged.items, "foobar");
} }
@ -2283,22 +2266,22 @@ test "fromOwnedSlice" {
test "fromOwnedSliceSentinel" { test "fromOwnedSliceSentinel" {
const a = testing.allocator; const a = testing.allocator;
{ {
var orig_list = ArrayList(u8).init(a); var orig_list = Managed(u8).init(a);
defer orig_list.deinit(); defer orig_list.deinit();
try orig_list.appendSlice("foobar"); try orig_list.appendSlice("foobar");
const sentinel_slice = try orig_list.toOwnedSliceSentinel(0); const sentinel_slice = try orig_list.toOwnedSliceSentinel(0);
var list = ArrayList(u8).fromOwnedSliceSentinel(a, 0, sentinel_slice); var list = Managed(u8).fromOwnedSliceSentinel(a, 0, sentinel_slice);
defer list.deinit(); defer list.deinit();
try testing.expectEqualStrings(list.items, "foobar"); try testing.expectEqualStrings(list.items, "foobar");
} }
{ {
var list = ArrayList(u8).init(a); var list = Managed(u8).init(a);
defer list.deinit(); defer list.deinit();
try list.appendSlice("foobar"); try list.appendSlice("foobar");
const sentinel_slice = try list.toOwnedSliceSentinel(0); const sentinel_slice = try list.toOwnedSliceSentinel(0);
var unmanaged = ArrayListUnmanaged(u8).fromOwnedSliceSentinel(0, sentinel_slice); var unmanaged = ArrayList(u8).fromOwnedSliceSentinel(0, sentinel_slice);
defer unmanaged.deinit(a); defer unmanaged.deinit(a);
try testing.expectEqualStrings(unmanaged.items, "foobar"); try testing.expectEqualStrings(unmanaged.items, "foobar");
} }
@ -2307,7 +2290,7 @@ test "fromOwnedSliceSentinel" {
test "toOwnedSliceSentinel" { test "toOwnedSliceSentinel" {
const a = testing.allocator; const a = testing.allocator;
{ {
var list = ArrayList(u8).init(a); var list = Managed(u8).init(a);
defer list.deinit(); defer list.deinit();
try list.appendSlice("foobar"); try list.appendSlice("foobar");
@ -2317,7 +2300,7 @@ test "toOwnedSliceSentinel" {
try testing.expectEqualStrings(result, mem.sliceTo(result.ptr, 0)); try testing.expectEqualStrings(result, mem.sliceTo(result.ptr, 0));
} }
{ {
var list: ArrayListUnmanaged(u8) = .empty; var list: ArrayList(u8) = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.appendSlice(a, "foobar"); try list.appendSlice(a, "foobar");
@ -2331,7 +2314,7 @@ test "toOwnedSliceSentinel" {
test "accepts unaligned slices" { test "accepts unaligned slices" {
const a = testing.allocator; const a = testing.allocator;
{ {
var list = std.ArrayListAligned(u8, .@"8").init(a); var list = AlignedManaged(u8, .@"8").init(a);
defer list.deinit(); defer list.deinit();
try list.appendSlice(&.{ 0, 1, 2, 3 }); try list.appendSlice(&.{ 0, 1, 2, 3 });
@ -2341,7 +2324,7 @@ test "accepts unaligned slices" {
try testing.expectEqualSlices(u8, list.items, &.{ 0, 8, 9, 6, 7, 2, 3 }); try testing.expectEqualSlices(u8, list.items, &.{ 0, 8, 9, 6, 7, 2, 3 });
} }
{ {
var list: std.ArrayListAlignedUnmanaged(u8, .@"8") = .empty; var list: Aligned(u8, .@"8") = .empty;
defer list.deinit(a); defer list.deinit(a);
try list.appendSlice(a, &.{ 0, 1, 2, 3 }); try list.appendSlice(a, &.{ 0, 1, 2, 3 });
@ -2352,11 +2335,11 @@ test "accepts unaligned slices" {
} }
} }
test "ArrayList(u0)" { test "Managed(u0)" {
// An ArrayList on zero-sized types should not need to allocate // An Managed on zero-sized types should not need to allocate
const a = testing.failing_allocator; const a = testing.failing_allocator;
var list = ArrayList(u0).init(a); var list = Managed(u0).init(a);
defer list.deinit(); defer list.deinit();
try list.append(0); try list.append(0);
@ -2372,10 +2355,10 @@ test "ArrayList(u0)" {
try testing.expectEqual(count, 3); try testing.expectEqual(count, 3);
} }
test "ArrayList(?u32).pop()" { test "Managed(?u32).pop()" {
const a = testing.allocator; const a = testing.allocator;
var list = ArrayList(?u32).init(a); var list = Managed(?u32).init(a);
defer list.deinit(); defer list.deinit();
try list.append(null); try list.append(null);
@ -2389,10 +2372,10 @@ test "ArrayList(?u32).pop()" {
try testing.expect(list.pop() == null); try testing.expect(list.pop() == null);
} }
test "ArrayList(u32).getLast()" { test "Managed(u32).getLast()" {
const a = testing.allocator; const a = testing.allocator;
var list = ArrayList(u32).init(a); var list = Managed(u32).init(a);
defer list.deinit(); defer list.deinit();
try list.append(2); try list.append(2);
@ -2400,10 +2383,10 @@ test "ArrayList(u32).getLast()" {
try testing.expectEqual(const_list.getLast(), 2); try testing.expectEqual(const_list.getLast(), 2);
} }
test "ArrayList(u32).getLastOrNull()" { test "Managed(u32).getLastOrNull()" {
const a = testing.allocator; const a = testing.allocator;
var list = ArrayList(u32).init(a); var list = Managed(u32).init(a);
defer list.deinit(); defer list.deinit();
try testing.expectEqual(list.getLastOrNull(), null); try testing.expectEqual(list.getLastOrNull(), null);
@ -2419,7 +2402,7 @@ test "return OutOfMemory when capacity would exceed maximum usize integer value"
const items = &.{ 42, 43 }; const items = &.{ 42, 43 };
{ {
var list: ArrayListUnmanaged(u32) = .{ var list: ArrayList(u32) = .{
.items = undefined, .items = undefined,
.capacity = math.maxInt(usize) - 1, .capacity = math.maxInt(usize) - 1,
}; };
@ -2436,7 +2419,7 @@ test "return OutOfMemory when capacity would exceed maximum usize integer value"
} }
{ {
var list: ArrayList(u32) = .{ var list: Managed(u32) = .{
.items = undefined, .items = undefined,
.capacity = math.maxInt(usize) - 1, .capacity = math.maxInt(usize) - 1,
.allocator = a, .allocator = a,
@ -2457,7 +2440,7 @@ test "return OutOfMemory when capacity would exceed maximum usize integer value"
test "orderedRemoveMany" { test "orderedRemoveMany" {
const gpa = testing.allocator; const gpa = testing.allocator;
var list: ArrayListUnmanaged(usize) = .empty; var list: Aligned(usize, null) = .empty;
defer list.deinit(gpa); defer list.deinit(gpa);
for (0..10) |n| { for (0..10) |n| {

View File

@ -18,7 +18,7 @@ test {
const compressed = &[_]u8{ 0x01, 0x00, 0x05, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x0A, 0x02, 0x00, 0x06, 0x57, 0x6F, 0x72, 0x6C, 0x64, 0x21, 0x0A, 0x00 }; const compressed = &[_]u8{ 0x01, 0x00, 0x05, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x0A, 0x02, 0x00, 0x06, 0x57, 0x6F, 0x72, 0x6C, 0x64, 0x21, 0x0A, 0x00 };
const allocator = std.testing.allocator; const allocator = std.testing.allocator;
var decomp = std.ArrayList(u8).init(allocator); var decomp = std.array_list.Managed(u8).init(allocator);
defer decomp.deinit(); defer decomp.deinit();
var stream = std.io.fixedBufferStream(compressed); var stream = std.io.fixedBufferStream(compressed);
try decompress(allocator, stream.reader(), decomp.writer()); try decompress(allocator, stream.reader(), decomp.writer());

View File

@ -14,7 +14,7 @@ const pwhash = crypto.pwhash;
const Thread = std.Thread; const Thread = std.Thread;
const Blake2b512 = blake2.Blake2b512; const Blake2b512 = blake2.Blake2b512;
const Blocks = std.ArrayListAligned([block_length]u64, .@"16"); const Blocks = std.array_list.AlignedManaged([block_length]u64, .@"16");
const H0 = [Blake2b512.digest_length + 8]u8; const H0 = [Blake2b512.digest_length + 8]u8;
const EncodingError = crypto.errors.EncodingError; const EncodingError = crypto.errors.EncodingError;
@ -252,7 +252,7 @@ fn processBlocksMt(
lanes: u32, lanes: u32,
segments: u32, segments: u32,
) KdfError!void { ) KdfError!void {
var threads_list = try std.ArrayList(Thread).initCapacity(allocator, threads); var threads_list = try std.array_list.Managed(Thread).initCapacity(allocator, threads);
defer threads_list.deinit(); defer threads_list.deinit();
var n: u32 = 0; var n: u32 = 0;
@ -507,7 +507,7 @@ pub fn kdf(
var blocks = try Blocks.initCapacity(allocator, memory); var blocks = try Blocks.initCapacity(allocator, memory);
defer blocks.deinit(); defer blocks.deinit();
blocks.appendNTimesAssumeCapacity([_]u64{0} ** block_length, memory); blocks.appendNTimesAssumeCapacity(@splat(0), memory);
initBlocks(&blocks, &h0, memory, params.p); initBlocks(&blocks, &h0, memory, params.p);
try processBlocks(allocator, &blocks, params.t, memory, params.p, mode); try processBlocks(allocator, &blocks, params.t, memory, params.p, mode);

View File

@ -27,6 +27,7 @@ const maxInt = std.math.maxInt;
const MemoryAccessor = std.debug.MemoryAccessor; const MemoryAccessor = std.debug.MemoryAccessor;
const Path = std.Build.Cache.Path; const Path = std.Build.Cache.Path;
const FixedBufferReader = std.debug.FixedBufferReader; const FixedBufferReader = std.debug.FixedBufferReader;
const ArrayList = std.ArrayList;
const Dwarf = @This(); const Dwarf = @This();
@ -42,11 +43,11 @@ sections: SectionArray = null_section_array,
is_macho: bool, is_macho: bool,
/// Filled later by the initializer /// Filled later by the initializer
abbrev_table_list: std.ArrayListUnmanaged(Abbrev.Table) = .empty, abbrev_table_list: ArrayList(Abbrev.Table) = .empty,
/// Filled later by the initializer /// Filled later by the initializer
compile_unit_list: std.ArrayListUnmanaged(CompileUnit) = .empty, compile_unit_list: ArrayList(CompileUnit) = .empty,
/// Filled later by the initializer /// Filled later by the initializer
func_list: std.ArrayListUnmanaged(Func) = .empty, func_list: ArrayList(Func) = .empty,
/// Starts out non-`null` if the `.eh_frame_hdr` section is present. May become `null` later if we /// Starts out non-`null` if the `.eh_frame_hdr` section is present. May become `null` later if we
/// find that `.eh_frame_hdr` is incomplete. /// find that `.eh_frame_hdr` is incomplete.
@ -54,10 +55,10 @@ eh_frame_hdr: ?ExceptionFrameHeader = null,
/// These lookup tables are only used if `eh_frame_hdr` is null /// These lookup tables are only used if `eh_frame_hdr` is null
cie_map: std.AutoArrayHashMapUnmanaged(u64, CommonInformationEntry) = .empty, cie_map: std.AutoArrayHashMapUnmanaged(u64, CommonInformationEntry) = .empty,
/// Sorted by start_pc /// Sorted by start_pc
fde_list: std.ArrayListUnmanaged(FrameDescriptionEntry) = .empty, fde_list: ArrayList(FrameDescriptionEntry) = .empty,
/// Populated by `populateRanges`. /// Populated by `populateRanges`.
ranges: std.ArrayListUnmanaged(Range) = .empty, ranges: ArrayList(Range) = .empty,
pub const Range = struct { pub const Range = struct {
start: u64, start: u64,
@ -1038,7 +1039,7 @@ fn scanAllCompileUnits(di: *Dwarf, allocator: Allocator) ScanError!void {
var fbr: FixedBufferReader = .{ .buf = di.section(.debug_info).?, .endian = di.endian }; var fbr: FixedBufferReader = .{ .buf = di.section(.debug_info).?, .endian = di.endian };
var this_unit_offset: u64 = 0; var this_unit_offset: u64 = 0;
var attrs_buf = std.ArrayList(Die.Attr).init(allocator); var attrs_buf = std.array_list.Managed(Die.Attr).init(allocator);
defer attrs_buf.deinit(); defer attrs_buf.deinit();
while (this_unit_offset < fbr.buf.len) { while (this_unit_offset < fbr.buf.len) {
@ -1343,7 +1344,7 @@ fn parseAbbrevTable(di: *Dwarf, allocator: Allocator, offset: u64) !Abbrev.Table
.endian = di.endian, .endian = di.endian,
}; };
var abbrevs = std.ArrayList(Abbrev).init(allocator); var abbrevs = std.array_list.Managed(Abbrev).init(allocator);
defer { defer {
for (abbrevs.items) |*abbrev| { for (abbrevs.items) |*abbrev| {
abbrev.deinit(allocator); abbrev.deinit(allocator);
@ -1351,7 +1352,7 @@ fn parseAbbrevTable(di: *Dwarf, allocator: Allocator, offset: u64) !Abbrev.Table
abbrevs.deinit(); abbrevs.deinit();
} }
var attrs = std.ArrayList(Abbrev.Attr).init(allocator); var attrs = std.array_list.Managed(Abbrev.Attr).init(allocator);
defer attrs.deinit(); defer attrs.deinit();
while (true) { while (true) {
@ -1468,9 +1469,9 @@ fn runLineNumberProgram(d: *Dwarf, gpa: Allocator, compile_unit: *CompileUnit) !
const standard_opcode_lengths = try fbr.readBytes(opcode_base - 1); const standard_opcode_lengths = try fbr.readBytes(opcode_base - 1);
var directories: std.ArrayListUnmanaged(FileEntry) = .empty; var directories: ArrayList(FileEntry) = .empty;
defer directories.deinit(gpa); defer directories.deinit(gpa);
var file_entries: std.ArrayListUnmanaged(FileEntry) = .empty; var file_entries: ArrayList(FileEntry) = .empty;
defer file_entries.deinit(gpa); defer file_entries.deinit(gpa);
if (version < 5) { if (version < 5) {
@ -2244,7 +2245,7 @@ pub const ElfModule = struct {
if (chdr.ch_type != .ZLIB) continue; if (chdr.ch_type != .ZLIB) continue;
var decompress: std.compress.flate.Decompress = .init(&section_reader, .zlib, &.{}); var decompress: std.compress.flate.Decompress = .init(&section_reader, .zlib, &.{});
var decompressed_section: std.ArrayListUnmanaged(u8) = .empty; var decompressed_section: ArrayList(u8) = .empty;
defer decompressed_section.deinit(gpa); defer decompressed_section.deinit(gpa);
decompress.reader.appendRemainingUnlimited(gpa, null, &decompressed_section, std.compress.flate.history_len) catch { decompress.reader.appendRemainingUnlimited(gpa, null, &decompressed_section, std.compress.flate.history_len) catch {
invalidDebugInfoDetected(); invalidDebugInfoDetected();

View File

@ -1064,7 +1064,7 @@ test "DWARF expressions" {
const b = Builder(options); const b = Builder(options);
var program = std.ArrayList(u8).init(allocator); var program = std.array_list.Managed(u8).init(allocator);
defer program.deinit(); defer program.deinit();
const writer = program.writer(); const writer = program.writer();
@ -1120,7 +1120,7 @@ test "DWARF expressions" {
var mock_compile_unit: std.debug.Dwarf.CompileUnit = undefined; var mock_compile_unit: std.debug.Dwarf.CompileUnit = undefined;
mock_compile_unit.addr_base = 1; mock_compile_unit.addr_base = 1;
var mock_debug_addr = std.ArrayList(u8).init(allocator); var mock_debug_addr = std.array_list.Managed(u8).init(allocator);
defer mock_debug_addr.deinit(); defer mock_debug_addr.deinit();
try mock_debug_addr.writer().writeInt(u16, 0, native_endian); try mock_debug_addr.writer().writeInt(u16, 0, native_endian);
@ -1590,7 +1590,7 @@ test "DWARF expressions" {
// Sub-expression // Sub-expression
{ {
var sub_program = std.ArrayList(u8).init(allocator); var sub_program = std.array_list.Managed(u8).init(allocator);
defer sub_program.deinit(); defer sub_program.deinit();
const sub_writer = sub_program.writer(); const sub_writer = sub_program.writer();
try b.writeLiteral(sub_writer, 3); try b.writeLiteral(sub_writer, 3);
@ -1617,7 +1617,7 @@ test "DWARF expressions" {
if (abi.regBytes(&thread_context, 0, reg_context)) |reg_bytes| { if (abi.regBytes(&thread_context, 0, reg_context)) |reg_bytes| {
mem.writeInt(usize, reg_bytes[0..@sizeOf(usize)], 0xee, native_endian); mem.writeInt(usize, reg_bytes[0..@sizeOf(usize)], 0xee, native_endian);
var sub_program = std.ArrayList(u8).init(allocator); var sub_program = std.array_list.Managed(u8).init(allocator);
defer sub_program.deinit(); defer sub_program.deinit();
const sub_writer = sub_program.writer(); const sub_writer = sub_program.writer();
try b.writeReg(sub_writer, 0); try b.writeReg(sub_writer, 0);

View File

@ -76,7 +76,7 @@ pub fn parseDbiStream(self: *Pdb) !void {
const mod_info_size = header.mod_info_size; const mod_info_size = header.mod_info_size;
const section_contrib_size = header.section_contribution_size; const section_contrib_size = header.section_contribution_size;
var modules = std.ArrayList(Module).init(self.allocator); var modules = std.array_list.Managed(Module).init(self.allocator);
errdefer modules.deinit(); errdefer modules.deinit();
// Module Info Substream // Module Info Substream
@ -117,7 +117,7 @@ pub fn parseDbiStream(self: *Pdb) !void {
} }
// Section Contribution Substream // Section Contribution Substream
var sect_contribs = std.ArrayList(pdb.SectionContribEntry).init(self.allocator); var sect_contribs = std.array_list.Managed(pdb.SectionContribEntry).init(self.allocator);
errdefer sect_contribs.deinit(); errdefer sect_contribs.deinit();
var sect_cont_offset: usize = 0; var sect_cont_offset: usize = 0;
@ -569,7 +569,7 @@ const MsfStream = struct {
fn readSparseBitVector(stream: anytype, allocator: Allocator) ![]u32 { fn readSparseBitVector(stream: anytype, allocator: Allocator) ![]u32 {
const num_words = try stream.readInt(u32, .little); const num_words = try stream.readInt(u32, .little);
var list = std.ArrayList(u32).init(allocator); var list = std.array_list.Managed(u32).init(allocator);
errdefer list.deinit(); errdefer list.deinit();
var word_i: u32 = 0; var word_i: u32 = 0;
while (word_i != num_words) : (word_i += 1) { while (word_i != num_words) : (word_i += 1) {

View File

@ -826,7 +826,7 @@ pub fn readToEndAllocOptions(
// size. If the reported size is zero, as it happens on Linux for files // size. If the reported size is zero, as it happens on Linux for files
// in /proc, a small buffer is allocated instead. // in /proc, a small buffer is allocated instead.
const initial_cap = @min((if (size > 0) size else 1024), max_bytes) + @intFromBool(optional_sentinel != null); const initial_cap = @min((if (size > 0) size else 1024), max_bytes) + @intFromBool(optional_sentinel != null);
var array_list = try std.ArrayListAligned(u8, alignment).initCapacity(allocator, initial_cap); var array_list = try std.array_list.AlignedManaged(u8, alignment).initCapacity(allocator, initial_cap);
defer array_list.deinit(); defer array_list.deinit();
self.deprecatedReader().readAllArrayListAligned(alignment, &array_list, max_bytes) catch |err| switch (err) { self.deprecatedReader().readAllArrayListAligned(alignment, &array_list, max_bytes) catch |err| switch (err) {

View File

@ -577,7 +577,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) ![]u8 {
} }
// Allocate result and fill in the disk designator. // Allocate result and fill in the disk designator.
var result = std.ArrayList(u8).init(allocator); var result = std.array_list.Managed(u8).init(allocator);
defer result.deinit(); defer result.deinit();
const disk_designator_len: usize = l: { const disk_designator_len: usize = l: {
@ -698,7 +698,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) ![]u8 {
pub fn resolvePosix(allocator: Allocator, paths: []const []const u8) Allocator.Error![]u8 { pub fn resolvePosix(allocator: Allocator, paths: []const []const u8) Allocator.Error![]u8 {
assert(paths.len > 0); assert(paths.len > 0);
var result = std.ArrayList(u8).init(allocator); var result = std.array_list.Managed(u8).init(allocator);
defer result.deinit(); defer result.deinit();
var negative_count: usize = 0; var negative_count: usize = 0;

View File

@ -464,7 +464,7 @@ test "Dir.Iterator" {
defer arena.deinit(); defer arena.deinit();
const allocator = arena.allocator(); const allocator = arena.allocator();
var entries = std.ArrayList(Dir.Entry).init(allocator); var entries = std.array_list.Managed(Dir.Entry).init(allocator);
// Create iterator. // Create iterator.
var iter = tmp_dir.dir.iterate(); var iter = tmp_dir.dir.iterate();
@ -497,7 +497,7 @@ test "Dir.Iterator many entries" {
defer arena.deinit(); defer arena.deinit();
const allocator = arena.allocator(); const allocator = arena.allocator();
var entries = std.ArrayList(Dir.Entry).init(allocator); var entries = std.array_list.Managed(Dir.Entry).init(allocator);
// Create iterator. // Create iterator.
var iter = tmp_dir.dir.iterate(); var iter = tmp_dir.dir.iterate();
@ -531,7 +531,7 @@ test "Dir.Iterator twice" {
var i: u8 = 0; var i: u8 = 0;
while (i < 2) : (i += 1) { while (i < 2) : (i += 1) {
var entries = std.ArrayList(Dir.Entry).init(allocator); var entries = std.array_list.Managed(Dir.Entry).init(allocator);
// Create iterator. // Create iterator.
var iter = tmp_dir.dir.iterate(); var iter = tmp_dir.dir.iterate();
@ -567,7 +567,7 @@ test "Dir.Iterator reset" {
var i: u8 = 0; var i: u8 = 0;
while (i < 2) : (i += 1) { while (i < 2) : (i += 1) {
var entries = std.ArrayList(Dir.Entry).init(allocator); var entries = std.array_list.Managed(Dir.Entry).init(allocator);
while (try iter.next()) |entry| { while (try iter.next()) |entry| {
// We cannot just store `entry` as on Windows, we're re-using the name buffer // We cannot just store `entry` as on Windows, we're re-using the name buffer
@ -617,7 +617,7 @@ fn entryEql(lhs: Dir.Entry, rhs: Dir.Entry) bool {
return mem.eql(u8, lhs.name, rhs.name) and lhs.kind == rhs.kind; return mem.eql(u8, lhs.name, rhs.name) and lhs.kind == rhs.kind;
} }
fn contains(entries: *const std.ArrayList(Dir.Entry), el: Dir.Entry) bool { fn contains(entries: *const std.array_list.Managed(Dir.Entry), el: Dir.Entry) bool {
for (entries.items) |entry| { for (entries.items) |entry| {
if (entryEql(entry, el)) return true; if (entryEql(entry, el)) return true;
} }

View File

@ -1800,7 +1800,7 @@ test "put and remove loop in random order" {
var map = AutoHashMap(u32, u32).init(std.testing.allocator); var map = AutoHashMap(u32, u32).init(std.testing.allocator);
defer map.deinit(); defer map.deinit();
var keys = std.ArrayList(u32).init(std.testing.allocator); var keys = std.array_list.Managed(u32).init(std.testing.allocator);
defer keys.deinit(); defer keys.deinit();
const size = 32; const size = 32;
@ -1834,7 +1834,7 @@ test "remove one million elements in random order" {
var map = Map.init(std.heap.page_allocator); var map = Map.init(std.heap.page_allocator);
defer map.deinit(); defer map.deinit();
var keys = std.ArrayList(u32).init(std.heap.page_allocator); var keys = std.array_list.Managed(u32).init(std.heap.page_allocator);
defer keys.deinit(); defer keys.deinit();
var i: u32 = 0; var i: u32 = 0;

View File

@ -673,7 +673,7 @@ pub fn testAllocatorAlignedShrink(base_allocator: mem.Allocator) !void {
var slice = try allocator.alignedAlloc(u8, .@"16", alloc_size); var slice = try allocator.alignedAlloc(u8, .@"16", alloc_size);
defer allocator.free(slice); defer allocator.free(slice);
var stuff_to_free = std.ArrayList([]align(16) u8).init(debug_allocator); var stuff_to_free = std.array_list.Managed([]align(16) u8).init(debug_allocator);
// On Windows, VirtualAlloc returns addresses aligned to a 64K boundary, // On Windows, VirtualAlloc returns addresses aligned to a 64K boundary,
// which is 16 pages, hence the 32. This test may require to increase // which is 16 pages, hence the 32. This test may require to increase
// the size of the allocations feeding the `allocator` parameter if they // the size of the allocations feeding the `allocator` parameter if they

View File

@ -1061,7 +1061,7 @@ test "small allocations - free in same order" {
defer std.testing.expect(gpa.deinit() == .ok) catch @panic("leak"); defer std.testing.expect(gpa.deinit() == .ok) catch @panic("leak");
const allocator = gpa.allocator(); const allocator = gpa.allocator();
var list = std.ArrayList(*u64).init(std.testing.allocator); var list = std.array_list.Managed(*u64).init(std.testing.allocator);
defer list.deinit(); defer list.deinit();
var i: usize = 0; var i: usize = 0;
@ -1080,7 +1080,7 @@ test "small allocations - free in reverse order" {
defer std.testing.expect(gpa.deinit() == .ok) catch @panic("leak"); defer std.testing.expect(gpa.deinit() == .ok) catch @panic("leak");
const allocator = gpa.allocator(); const allocator = gpa.allocator();
var list = std.ArrayList(*u64).init(std.testing.allocator); var list = std.array_list.Managed(*u64).init(std.testing.allocator);
defer list.deinit(); defer list.deinit();
var i: usize = 0; var i: usize = 0;
@ -1241,7 +1241,7 @@ test "shrink large object to large object with larger alignment" {
// This loop allocates until we find a page that is not aligned to the big // This loop allocates until we find a page that is not aligned to the big
// alignment. Then we shrink the allocation after the loop, but increase the // alignment. Then we shrink the allocation after the loop, but increase the
// alignment to the higher one, that we know will force it to realloc. // alignment to the higher one, that we know will force it to realloc.
var stuff_to_free = std.ArrayList([]align(16) u8).init(debug_allocator); var stuff_to_free = std.array_list.Managed([]align(16) u8).init(debug_allocator);
while (mem.isAligned(@intFromPtr(slice.ptr), big_alignment)) { while (mem.isAligned(@intFromPtr(slice.ptr), big_alignment)) {
try stuff_to_free.append(slice); try stuff_to_free.append(slice);
slice = try allocator.alignedAlloc(u8, .@"16", alloc_size); slice = try allocator.alignedAlloc(u8, .@"16", alloc_size);
@ -1313,7 +1313,7 @@ test "realloc large object to larger alignment" {
const big_alignment: usize = default_page_size * 2; const big_alignment: usize = default_page_size * 2;
// This loop allocates until we find a page that is not aligned to the big alignment. // This loop allocates until we find a page that is not aligned to the big alignment.
var stuff_to_free = std.ArrayList([]align(16) u8).init(debug_allocator); var stuff_to_free = std.array_list.Managed([]align(16) u8).init(debug_allocator);
while (mem.isAligned(@intFromPtr(slice.ptr), big_alignment)) { while (mem.isAligned(@intFromPtr(slice.ptr), big_alignment)) {
try stuff_to_free.append(slice); try stuff_to_free.append(slice);
slice = try allocator.alignedAlloc(u8, .@"16", default_page_size * 2 + 50); slice = try allocator.alignedAlloc(u8, .@"16", default_page_size * 2 + 50);

View File

@ -298,7 +298,7 @@ test "Server.Request.respondStreaming non-chunked, unknown content-length" {
const response = try stream_reader.interface().allocRemaining(gpa, .unlimited); const response = try stream_reader.interface().allocRemaining(gpa, .unlimited);
defer gpa.free(response); defer gpa.free(response);
var expected_response = std.ArrayList(u8).init(gpa); var expected_response = std.array_list.Managed(u8).init(gpa);
defer expected_response.deinit(); defer expected_response.deinit();
try expected_response.appendSlice("HTTP/1.1 200 OK\r\nconnection: close\r\n\r\n"); try expected_response.appendSlice("HTTP/1.1 200 OK\r\nconnection: close\r\n\r\n");
@ -369,7 +369,7 @@ test "receiving arbitrary http headers from the client" {
const response = try stream_reader.interface().allocRemaining(gpa, .unlimited); const response = try stream_reader.interface().allocRemaining(gpa, .unlimited);
defer gpa.free(response); defer gpa.free(response);
var expected_response = std.ArrayList(u8).init(gpa); var expected_response = std.array_list.Managed(u8).init(gpa);
defer expected_response.deinit(); defer expected_response.deinit();
try expected_response.appendSlice("HTTP/1.1 200 OK\r\n"); try expected_response.appendSlice("HTTP/1.1 200 OK\r\n");

View File

@ -46,7 +46,6 @@ const Scanner = @This();
const std = @import("std"); const std = @import("std");
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const assert = std.debug.assert; const assert = std.debug.assert;
const BitStack = std.BitStack; const BitStack = std.BitStack;
@ -136,7 +135,7 @@ pub fn nextAllocMax(self: *@This(), allocator: Allocator, when: AllocWhen, max_v
}; };
switch (token_type) { switch (token_type) {
.number, .string => { .number, .string => {
var value_list = ArrayList(u8).init(allocator); var value_list = std.array_list.Managed(u8).init(allocator);
errdefer { errdefer {
value_list.deinit(); value_list.deinit();
} }
@ -173,7 +172,7 @@ pub fn nextAllocMax(self: *@This(), allocator: Allocator, when: AllocWhen, max_v
} }
/// Equivalent to `allocNextIntoArrayListMax(value_list, when, default_max_value_len);` /// Equivalent to `allocNextIntoArrayListMax(value_list, when, default_max_value_len);`
pub fn allocNextIntoArrayList(self: *@This(), value_list: *ArrayList(u8), when: AllocWhen) AllocIntoArrayListError!?[]const u8 { pub fn allocNextIntoArrayList(self: *@This(), value_list: *std.array_list.Managed(u8), when: AllocWhen) AllocIntoArrayListError!?[]const u8 {
return self.allocNextIntoArrayListMax(value_list, when, default_max_value_len); return self.allocNextIntoArrayListMax(value_list, when, default_max_value_len);
} }
/// The next token type must be either `.number` or `.string`. See `peekNextTokenType()`. /// The next token type must be either `.number` or `.string`. See `peekNextTokenType()`.
@ -186,7 +185,7 @@ pub fn allocNextIntoArrayList(self: *@This(), value_list: *ArrayList(u8), when:
/// can be resumed by passing the same array list in again. /// can be resumed by passing the same array list in again.
/// This method does not indicate whether the token content being returned is for a `.number` or `.string` token type; /// This method does not indicate whether the token content being returned is for a `.number` or `.string` token type;
/// the caller of this method is expected to know which type of token is being processed. /// the caller of this method is expected to know which type of token is being processed.
pub fn allocNextIntoArrayListMax(self: *@This(), value_list: *ArrayList(u8), when: AllocWhen, max_value_len: usize) AllocIntoArrayListError!?[]const u8 { pub fn allocNextIntoArrayListMax(self: *@This(), value_list: *std.array_list.Managed(u8), when: AllocWhen, max_value_len: usize) AllocIntoArrayListError!?[]const u8 {
while (true) { while (true) {
const token = try self.next(); const token = try self.next();
switch (token) { switch (token) {
@ -1608,7 +1607,7 @@ pub const Reader = struct {
const token_type = try self.peekNextTokenType(); const token_type = try self.peekNextTokenType();
switch (token_type) { switch (token_type) {
.number, .string => { .number, .string => {
var value_list = ArrayList(u8).init(allocator); var value_list = std.array_list.Managed(u8).init(allocator);
errdefer { errdefer {
value_list.deinit(); value_list.deinit();
} }
@ -1639,11 +1638,11 @@ pub const Reader = struct {
} }
/// Equivalent to `allocNextIntoArrayListMax(value_list, when, default_max_value_len);` /// Equivalent to `allocNextIntoArrayListMax(value_list, when, default_max_value_len);`
pub fn allocNextIntoArrayList(self: *@This(), value_list: *ArrayList(u8), when: AllocWhen) Reader.AllocError!?[]const u8 { pub fn allocNextIntoArrayList(self: *@This(), value_list: *std.array_list.Managed(u8), when: AllocWhen) Reader.AllocError!?[]const u8 {
return self.allocNextIntoArrayListMax(value_list, when, default_max_value_len); return self.allocNextIntoArrayListMax(value_list, when, default_max_value_len);
} }
/// Calls `std.json.Scanner.allocNextIntoArrayListMax` and handles `error.BufferUnderrun`. /// Calls `std.json.Scanner.allocNextIntoArrayListMax` and handles `error.BufferUnderrun`.
pub fn allocNextIntoArrayListMax(self: *@This(), value_list: *ArrayList(u8), when: AllocWhen, max_value_len: usize) Reader.AllocError!?[]const u8 { pub fn allocNextIntoArrayListMax(self: *@This(), value_list: *std.array_list.Managed(u8), when: AllocWhen, max_value_len: usize) Reader.AllocError!?[]const u8 {
while (true) { while (true) {
return self.scanner.allocNextIntoArrayListMax(value_list, when, max_value_len) catch |err| switch (err) { return self.scanner.allocNextIntoArrayListMax(value_list, when, max_value_len) catch |err| switch (err) {
error.BufferUnderrun => { error.BufferUnderrun => {
@ -1746,7 +1745,7 @@ pub const Reader = struct {
const OBJECT_MODE = 0; const OBJECT_MODE = 0;
const ARRAY_MODE = 1; const ARRAY_MODE = 1;
fn appendSlice(list: *std.ArrayList(u8), buf: []const u8, max_value_len: usize) !void { fn appendSlice(list: *std.array_list.Managed(u8), buf: []const u8, max_value_len: usize) !void {
const new_len = std.math.add(usize, list.items.len, buf.len) catch return error.ValueTooLong; const new_len = std.math.add(usize, list.items.len, buf.len) catch return error.ValueTooLong;
if (new_len > max_value_len) return error.ValueTooLong; if (new_len > max_value_len) return error.ValueTooLong;
try list.appendSlice(buf); try list.appendSlice(buf);

View File

@ -1,7 +1,6 @@
const std = @import("std"); const std = @import("std");
const debug = std.debug; const debug = std.debug;
const ArenaAllocator = std.heap.ArenaAllocator; const ArenaAllocator = std.heap.ArenaAllocator;
const ArrayList = std.ArrayList;
const StringArrayHashMap = std.StringArrayHashMap; const StringArrayHashMap = std.StringArrayHashMap;
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const json = std.json; const json = std.json;
@ -12,7 +11,7 @@ const ParseError = @import("./static.zig").ParseError;
const isNumberFormattedLikeAnInteger = @import("Scanner.zig").isNumberFormattedLikeAnInteger; const isNumberFormattedLikeAnInteger = @import("Scanner.zig").isNumberFormattedLikeAnInteger;
pub const ObjectMap = StringArrayHashMap(Value); pub const ObjectMap = StringArrayHashMap(Value);
pub const Array = ArrayList(Value); pub const Array = std.array_list.Managed(Value);
/// Represents any JSON value, potentially containing other JSON values. /// Represents any JSON value, potentially containing other JSON values.
/// A .float value may be an approximation of the original value. /// A .float value may be an approximation of the original value.

View File

@ -2,7 +2,7 @@ const std = @import("std");
const assert = std.debug.assert; const assert = std.debug.assert;
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator; const ArenaAllocator = std.heap.ArenaAllocator;
const ArrayList = std.ArrayList; const ArrayList = std.array_list.Managed;
const Scanner = @import("Scanner.zig"); const Scanner = @import("Scanner.zig");
const Token = Scanner.Token; const Token = Scanner.Token;

View File

@ -1412,7 +1412,7 @@ pub const Mutable = struct {
/// ///
/// `limbs_buffer` is used for temporary storage during the operation. When this function returns, /// `limbs_buffer` is used for temporary storage during the operation. When this function returns,
/// it will have the same length as it had when the function was called. /// it will have the same length as it had when the function was called.
pub fn gcd(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void { pub fn gcd(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.array_list.Managed(Limb)) !void {
const prev_len = limbs_buffer.items.len; const prev_len = limbs_buffer.items.len;
defer limbs_buffer.shrinkRetainingCapacity(prev_len); defer limbs_buffer.shrinkRetainingCapacity(prev_len);
const x_copy = if (rma.limbs.ptr == x.limbs.ptr) blk: { const x_copy = if (rma.limbs.ptr == x.limbs.ptr) blk: {
@ -1538,13 +1538,13 @@ pub const Mutable = struct {
/// Asserts that `rma` has enough limbs to store the result. Upper bound is given by `calcGcdNoAliasLimbLen`. /// Asserts that `rma` has enough limbs to store the result. Upper bound is given by `calcGcdNoAliasLimbLen`.
/// ///
/// `limbs_buffer` is used for temporary storage during the operation. /// `limbs_buffer` is used for temporary storage during the operation.
pub fn gcdNoAlias(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void { pub fn gcdNoAlias(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.array_list.Managed(Limb)) !void {
assert(rma.limbs.ptr != x.limbs.ptr); // illegal aliasing assert(rma.limbs.ptr != x.limbs.ptr); // illegal aliasing
assert(rma.limbs.ptr != y.limbs.ptr); // illegal aliasing assert(rma.limbs.ptr != y.limbs.ptr); // illegal aliasing
return gcdLehmer(rma, x, y, limbs_buffer); return gcdLehmer(rma, x, y, limbs_buffer);
} }
fn gcdLehmer(result: *Mutable, xa: Const, ya: Const, limbs_buffer: *std.ArrayList(Limb)) !void { fn gcdLehmer(result: *Mutable, xa: Const, ya: Const, limbs_buffer: *std.array_list.Managed(Limb)) !void {
var x = try xa.toManaged(limbs_buffer.allocator); var x = try xa.toManaged(limbs_buffer.allocator);
defer x.deinit(); defer x.deinit();
x.abs(); x.abs();
@ -3267,7 +3267,7 @@ pub const Managed = struct {
pub fn gcd(rma: *Managed, x: *const Managed, y: *const Managed) !void { pub fn gcd(rma: *Managed, x: *const Managed, y: *const Managed) !void {
try rma.ensureCapacity(@min(x.len(), y.len())); try rma.ensureCapacity(@min(x.len(), y.len()));
var m = rma.toMutable(); var m = rma.toMutable();
var limbs_buffer = std.ArrayList(Limb).init(rma.allocator); var limbs_buffer = std.array_list.Managed(Limb).init(rma.allocator);
defer limbs_buffer.deinit(); defer limbs_buffer.deinit();
try m.gcd(x.toConst(), y.toConst(), &limbs_buffer); try m.gcd(x.toConst(), y.toConst(), &limbs_buffer);
rma.setMetadata(m.positive, m.len); rma.setMetadata(m.positive, m.len);

View File

@ -964,7 +964,7 @@ fn fuzzTestMinMax(rng: std.Random, queue_size: usize) !void {
} }
fn generateRandomSlice(allocator: std.mem.Allocator, rng: std.Random, size: usize) ![]u32 { fn generateRandomSlice(allocator: std.mem.Allocator, rng: std.Random, size: usize) ![]u32 {
var array = std.ArrayList(u32).init(allocator); var array = std.array_list.Managed(u32).init(allocator);
try array.ensureTotalCapacity(size); try array.ensureTotalCapacity(size);
var i: usize = 0; var i: usize = 0;

View File

@ -1241,10 +1241,10 @@ pub fn argsAlloc(allocator: Allocator) ![][:0]u8 {
var it = try argsWithAllocator(allocator); var it = try argsWithAllocator(allocator);
defer it.deinit(); defer it.deinit();
var contents = std.ArrayList(u8).init(allocator); var contents = std.array_list.Managed(u8).init(allocator);
defer contents.deinit(); defer contents.deinit();
var slice_list = std.ArrayList(usize).init(allocator); var slice_list = std.array_list.Managed(usize).init(allocator);
defer slice_list.deinit(); defer slice_list.deinit();
while (it.next()) |arg| { while (it.next()) |arg| {

View File

@ -14,7 +14,7 @@ const assert = std.debug.assert;
const native_os = builtin.os.tag; const native_os = builtin.os.tag;
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const ChildProcess = @This(); const ChildProcess = @This();
const ArrayList = std.ArrayListUnmanaged; const ArrayList = std.ArrayList;
pub const Id = switch (native_os) { pub const Id = switch (native_os) {
.windows => windows.HANDLE, .windows => windows.HANDLE,
@ -1545,7 +1545,7 @@ fn argvToCommandLineWindows(
allocator: mem.Allocator, allocator: mem.Allocator,
argv: []const []const u8, argv: []const []const u8,
) ArgvToCommandLineError![:0]u16 { ) ArgvToCommandLineError![:0]u16 {
var buf = std.ArrayList(u8).init(allocator); var buf = std.array_list.Managed(u8).init(allocator);
defer buf.deinit(); defer buf.deinit();
if (argv.len != 0) { if (argv.len != 0) {
@ -1725,7 +1725,7 @@ fn argvToScriptCommandLineWindows(
/// Arguments, not including the script name itself. Expected to be encoded as WTF-8. /// Arguments, not including the script name itself. Expected to be encoded as WTF-8.
script_args: []const []const u8, script_args: []const []const u8,
) ArgvToScriptCommandLineError![:0]u16 { ) ArgvToScriptCommandLineError![:0]u16 {
var buf = try std.ArrayList(u8).initCapacity(allocator, 64); var buf = try std.array_list.Managed(u8).initCapacity(allocator, 64);
defer buf.deinit(); defer buf.deinit();
// `/d` disables execution of AutoRun commands. // `/d` disables execution of AutoRun commands.

View File

@ -1,9 +1,5 @@
pub const ArrayHashMap = array_hash_map.ArrayHashMap; pub const ArrayHashMap = array_hash_map.ArrayHashMap;
pub const ArrayHashMapUnmanaged = array_hash_map.ArrayHashMapUnmanaged; pub const ArrayHashMapUnmanaged = array_hash_map.ArrayHashMapUnmanaged;
pub const ArrayList = @import("array_list.zig").ArrayList;
pub const ArrayListAligned = @import("array_list.zig").ArrayListAligned;
pub const ArrayListAlignedUnmanaged = @import("array_list.zig").ArrayListAlignedUnmanaged;
pub const ArrayListUnmanaged = @import("array_list.zig").ArrayListUnmanaged;
pub const AutoArrayHashMap = array_hash_map.AutoArrayHashMap; pub const AutoArrayHashMap = array_hash_map.AutoArrayHashMap;
pub const AutoArrayHashMapUnmanaged = array_hash_map.AutoArrayHashMapUnmanaged; pub const AutoArrayHashMapUnmanaged = array_hash_map.AutoArrayHashMapUnmanaged;
pub const AutoHashMap = hash_map.AutoHashMap; pub const AutoHashMap = hash_map.AutoHashMap;
@ -43,6 +39,24 @@ pub const Treap = @import("treap.zig").Treap;
pub const Tz = tz.Tz; pub const Tz = tz.Tz;
pub const Uri = @import("Uri.zig"); pub const Uri = @import("Uri.zig");
/// A contiguous, growable list of items in memory. This is a wrapper around a
/// slice of `T` values.
///
/// The same allocator must be used throughout its entire lifetime. Initialize
/// directly with `empty` or `initCapacity`, and deinitialize with `deinit` or
/// `toOwnedSlice`.
pub fn ArrayList(comptime T: type) type {
return array_list.Aligned(T, null);
}
pub const array_list = @import("array_list.zig");
/// Deprecated; use `array_list.Aligned`.
pub const ArrayListAligned = array_list.Aligned;
/// Deprecated; use `array_list.Aligned`.
pub const ArrayListAlignedUnmanaged = array_list.Aligned;
/// Deprecated; use `ArrayList`.
pub const ArrayListUnmanaged = ArrayList;
pub const array_hash_map = @import("array_hash_map.zig"); pub const array_hash_map = @import("array_hash_map.zig");
pub const atomic = @import("atomic.zig"); pub const atomic = @import("atomic.zig");
pub const base64 = @import("base64.zig"); pub const base64 = @import("base64.zig");

View File

@ -641,7 +641,7 @@ test "node.{prev(),next()} with random data" {
var treap = TestTreap{}; var treap = TestTreap{};
// A slow, stupid but correct reference. Ordered. // A slow, stupid but correct reference. Ordered.
var golden = std.ArrayList(u64).init(std.testing.allocator); var golden = std.array_list.Managed(u64).init(std.testing.allocator);
defer golden.deinit(); defer golden.deinit();
// Insert. // Insert.

View File

@ -916,7 +916,7 @@ test fmtUtf8 {
} }
fn utf16LeToUtf8ArrayListImpl( fn utf16LeToUtf8ArrayListImpl(
result: *std.ArrayList(u8), result: *std.array_list.Managed(u8),
utf16le: []const u16, utf16le: []const u16,
comptime surrogates: Surrogates, comptime surrogates: Surrogates,
) (switch (surrogates) { ) (switch (surrogates) {
@ -967,7 +967,7 @@ fn utf16LeToUtf8ArrayListImpl(
pub const Utf16LeToUtf8AllocError = mem.Allocator.Error || Utf16LeToUtf8Error; pub const Utf16LeToUtf8AllocError = mem.Allocator.Error || Utf16LeToUtf8Error;
pub fn utf16LeToUtf8ArrayList(result: *std.ArrayList(u8), utf16le: []const u16) Utf16LeToUtf8AllocError!void { pub fn utf16LeToUtf8ArrayList(result: *std.array_list.Managed(u8), utf16le: []const u16) Utf16LeToUtf8AllocError!void {
try result.ensureUnusedCapacity(utf16le.len); try result.ensureUnusedCapacity(utf16le.len);
return utf16LeToUtf8ArrayListImpl(result, utf16le, .cannot_encode_surrogate_half); return utf16LeToUtf8ArrayListImpl(result, utf16le, .cannot_encode_surrogate_half);
} }
@ -975,7 +975,7 @@ pub fn utf16LeToUtf8ArrayList(result: *std.ArrayList(u8), utf16le: []const u16)
/// Caller must free returned memory. /// Caller must free returned memory.
pub fn utf16LeToUtf8Alloc(allocator: mem.Allocator, utf16le: []const u16) Utf16LeToUtf8AllocError![]u8 { pub fn utf16LeToUtf8Alloc(allocator: mem.Allocator, utf16le: []const u16) Utf16LeToUtf8AllocError![]u8 {
// optimistically guess that it will all be ascii. // optimistically guess that it will all be ascii.
var result = try std.ArrayList(u8).initCapacity(allocator, utf16le.len); var result = try std.array_list.Managed(u8).initCapacity(allocator, utf16le.len);
errdefer result.deinit(); errdefer result.deinit();
try utf16LeToUtf8ArrayListImpl(&result, utf16le, .cannot_encode_surrogate_half); try utf16LeToUtf8ArrayListImpl(&result, utf16le, .cannot_encode_surrogate_half);
@ -985,7 +985,7 @@ pub fn utf16LeToUtf8Alloc(allocator: mem.Allocator, utf16le: []const u16) Utf16L
/// Caller must free returned memory. /// Caller must free returned memory.
pub fn utf16LeToUtf8AllocZ(allocator: mem.Allocator, utf16le: []const u16) Utf16LeToUtf8AllocError![:0]u8 { pub fn utf16LeToUtf8AllocZ(allocator: mem.Allocator, utf16le: []const u16) Utf16LeToUtf8AllocError![:0]u8 {
// optimistically guess that it will all be ascii (and allocate space for the null terminator) // optimistically guess that it will all be ascii (and allocate space for the null terminator)
var result = try std.ArrayList(u8).initCapacity(allocator, utf16le.len + 1); var result = try std.array_list.Managed(u8).initCapacity(allocator, utf16le.len + 1);
errdefer result.deinit(); errdefer result.deinit();
try utf16LeToUtf8ArrayListImpl(&result, utf16le, .cannot_encode_surrogate_half); try utf16LeToUtf8ArrayListImpl(&result, utf16le, .cannot_encode_surrogate_half);
@ -1117,7 +1117,7 @@ test utf16LeToUtf8 {
} }
} }
fn utf8ToUtf16LeArrayListImpl(result: *std.ArrayList(u16), utf8: []const u8, comptime surrogates: Surrogates) !void { fn utf8ToUtf16LeArrayListImpl(result: *std.array_list.Managed(u16), utf8: []const u8, comptime surrogates: Surrogates) !void {
assert(result.unusedCapacitySlice().len >= utf8.len); assert(result.unusedCapacitySlice().len >= utf8.len);
var remaining = utf8; var remaining = utf8;
@ -1155,14 +1155,14 @@ fn utf8ToUtf16LeArrayListImpl(result: *std.ArrayList(u16), utf8: []const u8, com
} }
} }
pub fn utf8ToUtf16LeArrayList(result: *std.ArrayList(u16), utf8: []const u8) error{ InvalidUtf8, OutOfMemory }!void { pub fn utf8ToUtf16LeArrayList(result: *std.array_list.Managed(u16), utf8: []const u8) error{ InvalidUtf8, OutOfMemory }!void {
try result.ensureUnusedCapacity(utf8.len); try result.ensureUnusedCapacity(utf8.len);
return utf8ToUtf16LeArrayListImpl(result, utf8, .cannot_encode_surrogate_half); return utf8ToUtf16LeArrayListImpl(result, utf8, .cannot_encode_surrogate_half);
} }
pub fn utf8ToUtf16LeAlloc(allocator: mem.Allocator, utf8: []const u8) error{ InvalidUtf8, OutOfMemory }![]u16 { pub fn utf8ToUtf16LeAlloc(allocator: mem.Allocator, utf8: []const u8) error{ InvalidUtf8, OutOfMemory }![]u16 {
// optimistically guess that it will not require surrogate pairs // optimistically guess that it will not require surrogate pairs
var result = try std.ArrayList(u16).initCapacity(allocator, utf8.len); var result = try std.array_list.Managed(u16).initCapacity(allocator, utf8.len);
errdefer result.deinit(); errdefer result.deinit();
try utf8ToUtf16LeArrayListImpl(&result, utf8, .cannot_encode_surrogate_half); try utf8ToUtf16LeArrayListImpl(&result, utf8, .cannot_encode_surrogate_half);
@ -1171,7 +1171,7 @@ pub fn utf8ToUtf16LeAlloc(allocator: mem.Allocator, utf8: []const u8) error{ Inv
pub fn utf8ToUtf16LeAllocZ(allocator: mem.Allocator, utf8: []const u8) error{ InvalidUtf8, OutOfMemory }![:0]u16 { pub fn utf8ToUtf16LeAllocZ(allocator: mem.Allocator, utf8: []const u8) error{ InvalidUtf8, OutOfMemory }![:0]u16 {
// optimistically guess that it will not require surrogate pairs // optimistically guess that it will not require surrogate pairs
var result = try std.ArrayList(u16).initCapacity(allocator, utf8.len + 1); var result = try std.array_list.Managed(u16).initCapacity(allocator, utf8.len + 1);
errdefer result.deinit(); errdefer result.deinit();
try utf8ToUtf16LeArrayListImpl(&result, utf8, .cannot_encode_surrogate_half); try utf8ToUtf16LeArrayListImpl(&result, utf8, .cannot_encode_surrogate_half);
@ -1258,19 +1258,19 @@ test utf8ToUtf16Le {
test utf8ToUtf16LeArrayList { test utf8ToUtf16LeArrayList {
{ {
var list = std.ArrayList(u16).init(testing.allocator); var list = std.array_list.Managed(u16).init(testing.allocator);
defer list.deinit(); defer list.deinit();
try utf8ToUtf16LeArrayList(&list, "𐐷"); try utf8ToUtf16LeArrayList(&list, "𐐷");
try testing.expectEqualSlices(u8, "\x01\xd8\x37\xdc", mem.sliceAsBytes(list.items)); try testing.expectEqualSlices(u8, "\x01\xd8\x37\xdc", mem.sliceAsBytes(list.items));
} }
{ {
var list = std.ArrayList(u16).init(testing.allocator); var list = std.array_list.Managed(u16).init(testing.allocator);
defer list.deinit(); defer list.deinit();
try utf8ToUtf16LeArrayList(&list, "\u{10FFFF}"); try utf8ToUtf16LeArrayList(&list, "\u{10FFFF}");
try testing.expectEqualSlices(u8, "\xff\xdb\xff\xdf", mem.sliceAsBytes(list.items)); try testing.expectEqualSlices(u8, "\xff\xdb\xff\xdf", mem.sliceAsBytes(list.items));
} }
{ {
var list = std.ArrayList(u16).init(testing.allocator); var list = std.array_list.Managed(u16).init(testing.allocator);
defer list.deinit(); defer list.deinit();
const result = utf8ToUtf16LeArrayList(&list, "\xf4\x90\x80\x80"); const result = utf8ToUtf16LeArrayList(&list, "\xf4\x90\x80\x80");
try testing.expectError(error.InvalidUtf8, result); try testing.expectError(error.InvalidUtf8, result);
@ -1331,7 +1331,7 @@ test utf8ToUtf16LeAllocZ {
test "ArrayList functions on a re-used list" { test "ArrayList functions on a re-used list" {
// utf8ToUtf16LeArrayList // utf8ToUtf16LeArrayList
{ {
var list = std.ArrayList(u16).init(testing.allocator); var list = std.array_list.Managed(u16).init(testing.allocator);
defer list.deinit(); defer list.deinit();
const init_slice = utf8ToUtf16LeStringLiteral("abcdefg"); const init_slice = utf8ToUtf16LeStringLiteral("abcdefg");
@ -1345,7 +1345,7 @@ test "ArrayList functions on a re-used list" {
// utf16LeToUtf8ArrayList // utf16LeToUtf8ArrayList
{ {
var list = std.ArrayList(u8).init(testing.allocator); var list = std.array_list.Managed(u8).init(testing.allocator);
defer list.deinit(); defer list.deinit();
const init_slice = "abcdefg"; const init_slice = "abcdefg";
@ -1359,7 +1359,7 @@ test "ArrayList functions on a re-used list" {
// wtf8ToWtf16LeArrayList // wtf8ToWtf16LeArrayList
{ {
var list = std.ArrayList(u16).init(testing.allocator); var list = std.array_list.Managed(u16).init(testing.allocator);
defer list.deinit(); defer list.deinit();
const init_slice = utf8ToUtf16LeStringLiteral("abcdefg"); const init_slice = utf8ToUtf16LeStringLiteral("abcdefg");
@ -1373,7 +1373,7 @@ test "ArrayList functions on a re-used list" {
// wtf16LeToWtf8ArrayList // wtf16LeToWtf8ArrayList
{ {
var list = std.ArrayList(u8).init(testing.allocator); var list = std.array_list.Managed(u8).init(testing.allocator);
defer list.deinit(); defer list.deinit();
const init_slice = "abcdefg"; const init_slice = "abcdefg";
@ -1750,7 +1750,7 @@ pub const Wtf8Iterator = struct {
} }
}; };
pub fn wtf16LeToWtf8ArrayList(result: *std.ArrayList(u8), utf16le: []const u16) mem.Allocator.Error!void { pub fn wtf16LeToWtf8ArrayList(result: *std.array_list.Managed(u8), utf16le: []const u16) mem.Allocator.Error!void {
try result.ensureUnusedCapacity(utf16le.len); try result.ensureUnusedCapacity(utf16le.len);
return utf16LeToUtf8ArrayListImpl(result, utf16le, .can_encode_surrogate_half); return utf16LeToUtf8ArrayListImpl(result, utf16le, .can_encode_surrogate_half);
} }
@ -1758,7 +1758,7 @@ pub fn wtf16LeToWtf8ArrayList(result: *std.ArrayList(u8), utf16le: []const u16)
/// Caller must free returned memory. /// Caller must free returned memory.
pub fn wtf16LeToWtf8Alloc(allocator: mem.Allocator, wtf16le: []const u16) mem.Allocator.Error![]u8 { pub fn wtf16LeToWtf8Alloc(allocator: mem.Allocator, wtf16le: []const u16) mem.Allocator.Error![]u8 {
// optimistically guess that it will all be ascii. // optimistically guess that it will all be ascii.
var result = try std.ArrayList(u8).initCapacity(allocator, wtf16le.len); var result = try std.array_list.Managed(u8).initCapacity(allocator, wtf16le.len);
errdefer result.deinit(); errdefer result.deinit();
try utf16LeToUtf8ArrayListImpl(&result, wtf16le, .can_encode_surrogate_half); try utf16LeToUtf8ArrayListImpl(&result, wtf16le, .can_encode_surrogate_half);
@ -1768,7 +1768,7 @@ pub fn wtf16LeToWtf8Alloc(allocator: mem.Allocator, wtf16le: []const u16) mem.Al
/// Caller must free returned memory. /// Caller must free returned memory.
pub fn wtf16LeToWtf8AllocZ(allocator: mem.Allocator, wtf16le: []const u16) mem.Allocator.Error![:0]u8 { pub fn wtf16LeToWtf8AllocZ(allocator: mem.Allocator, wtf16le: []const u16) mem.Allocator.Error![:0]u8 {
// optimistically guess that it will all be ascii (and allocate space for the null terminator) // optimistically guess that it will all be ascii (and allocate space for the null terminator)
var result = try std.ArrayList(u8).initCapacity(allocator, wtf16le.len + 1); var result = try std.array_list.Managed(u8).initCapacity(allocator, wtf16le.len + 1);
errdefer result.deinit(); errdefer result.deinit();
try utf16LeToUtf8ArrayListImpl(&result, wtf16le, .can_encode_surrogate_half); try utf16LeToUtf8ArrayListImpl(&result, wtf16le, .can_encode_surrogate_half);
@ -1779,14 +1779,14 @@ pub fn wtf16LeToWtf8(wtf8: []u8, wtf16le: []const u16) usize {
return utf16LeToUtf8Impl(wtf8, wtf16le, .can_encode_surrogate_half) catch |err| switch (err) {}; return utf16LeToUtf8Impl(wtf8, wtf16le, .can_encode_surrogate_half) catch |err| switch (err) {};
} }
pub fn wtf8ToWtf16LeArrayList(result: *std.ArrayList(u16), wtf8: []const u8) error{ InvalidWtf8, OutOfMemory }!void { pub fn wtf8ToWtf16LeArrayList(result: *std.array_list.Managed(u16), wtf8: []const u8) error{ InvalidWtf8, OutOfMemory }!void {
try result.ensureUnusedCapacity(wtf8.len); try result.ensureUnusedCapacity(wtf8.len);
return utf8ToUtf16LeArrayListImpl(result, wtf8, .can_encode_surrogate_half); return utf8ToUtf16LeArrayListImpl(result, wtf8, .can_encode_surrogate_half);
} }
pub fn wtf8ToWtf16LeAlloc(allocator: mem.Allocator, wtf8: []const u8) error{ InvalidWtf8, OutOfMemory }![]u16 { pub fn wtf8ToWtf16LeAlloc(allocator: mem.Allocator, wtf8: []const u8) error{ InvalidWtf8, OutOfMemory }![]u16 {
// optimistically guess that it will not require surrogate pairs // optimistically guess that it will not require surrogate pairs
var result = try std.ArrayList(u16).initCapacity(allocator, wtf8.len); var result = try std.array_list.Managed(u16).initCapacity(allocator, wtf8.len);
errdefer result.deinit(); errdefer result.deinit();
try utf8ToUtf16LeArrayListImpl(&result, wtf8, .can_encode_surrogate_half); try utf8ToUtf16LeArrayListImpl(&result, wtf8, .can_encode_surrogate_half);
@ -1795,7 +1795,7 @@ pub fn wtf8ToWtf16LeAlloc(allocator: mem.Allocator, wtf8: []const u8) error{ Inv
pub fn wtf8ToWtf16LeAllocZ(allocator: mem.Allocator, wtf8: []const u8) error{ InvalidWtf8, OutOfMemory }![:0]u16 { pub fn wtf8ToWtf16LeAllocZ(allocator: mem.Allocator, wtf8: []const u8) error{ InvalidWtf8, OutOfMemory }![:0]u16 {
// optimistically guess that it will not require surrogate pairs // optimistically guess that it will not require surrogate pairs
var result = try std.ArrayList(u16).initCapacity(allocator, wtf8.len + 1); var result = try std.array_list.Managed(u16).initCapacity(allocator, wtf8.len + 1);
errdefer result.deinit(); errdefer result.deinit();
try utf8ToUtf16LeArrayListImpl(&result, wtf8, .can_encode_surrogate_half); try utf8ToUtf16LeArrayListImpl(&result, wtf8, .can_encode_surrogate_half);

View File

@ -349,7 +349,7 @@ pub const LtoMode = enum { none, full, thin };
/// Renders a `std.Target.Cpu` value into a textual representation that can be parsed /// Renders a `std.Target.Cpu` value into a textual representation that can be parsed
/// via the `-mcpu` flag passed to the Zig compiler. /// via the `-mcpu` flag passed to the Zig compiler.
/// Appends the result to `buffer`. /// Appends the result to `buffer`.
pub fn serializeCpu(buffer: *std.ArrayList(u8), cpu: std.Target.Cpu) Allocator.Error!void { pub fn serializeCpu(buffer: *std.array_list.Managed(u8), cpu: std.Target.Cpu) Allocator.Error!void {
const all_features = cpu.arch.allFeaturesList(); const all_features = cpu.arch.allFeaturesList();
var populated_cpu_features = cpu.model.features; var populated_cpu_features = cpu.model.features;
populated_cpu_features.populateDependencies(all_features); populated_cpu_features.populateDependencies(all_features);
@ -377,7 +377,7 @@ pub fn serializeCpu(buffer: *std.ArrayList(u8), cpu: std.Target.Cpu) Allocator.E
} }
pub fn serializeCpuAlloc(ally: Allocator, cpu: std.Target.Cpu) Allocator.Error![]u8 { pub fn serializeCpuAlloc(ally: Allocator, cpu: std.Target.Cpu) Allocator.Error![]u8 {
var buffer = std.ArrayList(u8).init(ally); var buffer = std.array_list.Managed(u8).init(ally);
try serializeCpu(&buffer, cpu); try serializeCpu(&buffer, cpu);
return buffer.toOwnedSlice(); return buffer.toOwnedSlice();
} }
@ -633,7 +633,7 @@ pub fn parseTargetQueryOrReportFatalError(
return std.Target.Query.parse(opts_with_diags) catch |err| switch (err) { return std.Target.Query.parse(opts_with_diags) catch |err| switch (err) {
error.UnknownCpuModel => { error.UnknownCpuModel => {
help: { help: {
var help_text = std.ArrayList(u8).init(allocator); var help_text = std.array_list.Managed(u8).init(allocator);
defer help_text.deinit(); defer help_text.deinit();
for (diags.arch.?.allCpuModels()) |cpu| { for (diags.arch.?.allCpuModels()) |cpu| {
help_text.print(" {s}\n", .{cpu.name}) catch break :help; help_text.print(" {s}\n", .{cpu.name}) catch break :help;
@ -646,7 +646,7 @@ pub fn parseTargetQueryOrReportFatalError(
}, },
error.UnknownCpuFeature => { error.UnknownCpuFeature => {
help: { help: {
var help_text = std.ArrayList(u8).init(allocator); var help_text = std.array_list.Managed(u8).init(allocator);
defer help_text.deinit(); defer help_text.deinit();
for (diags.arch.?.allFeaturesList()) |feature| { for (diags.arch.?.allFeaturesList()) |feature| {
help_text.print(" {s}: {s}\n", .{ feature.name, feature.description }) catch break :help; help_text.print(" {s}: {s}\n", .{ feature.name, feature.description }) catch break :help;
@ -659,7 +659,7 @@ pub fn parseTargetQueryOrReportFatalError(
}, },
error.UnknownObjectFormat => { error.UnknownObjectFormat => {
help: { help: {
var help_text = std.ArrayList(u8).init(allocator); var help_text = std.array_list.Managed(u8).init(allocator);
defer help_text.deinit(); defer help_text.deinit();
inline for (@typeInfo(std.Target.ObjectFormat).@"enum".fields) |field| { inline for (@typeInfo(std.Target.ObjectFormat).@"enum".fields) |field| {
help_text.print(" {s}\n", .{field.name}) catch break :help; help_text.print(" {s}\n", .{field.name}) catch break :help;
@ -670,7 +670,7 @@ pub fn parseTargetQueryOrReportFatalError(
}, },
error.UnknownArchitecture => { error.UnknownArchitecture => {
help: { help: {
var help_text = std.ArrayList(u8).init(allocator); var help_text = std.array_list.Managed(u8).init(allocator);
defer help_text.deinit(); defer help_text.deinit();
inline for (@typeInfo(std.Target.Cpu.Arch).@"enum".fields) |field| { inline for (@typeInfo(std.Target.Cpu.Arch).@"enum".fields) |field| {
help_text.print(" {s}\n", .{field.name}) catch break :help; help_text.print(" {s}\n", .{field.name}) catch break :help;

View File

@ -3456,8 +3456,8 @@ const AutoIndentingStream = struct {
indent_count: usize = 0, indent_count: usize = 0,
indent_delta: usize, indent_delta: usize,
indent_stack: std.ArrayList(StackElem), indent_stack: std.array_list.Managed(StackElem),
space_stack: std.ArrayList(SpaceElem), space_stack: std.array_list.Managed(SpaceElem),
space_mode: ?usize = null, space_mode: ?usize = null,
disable_indent_committing: usize = 0, disable_indent_committing: usize = 0,
current_line_empty: bool = true, current_line_empty: bool = true,

View File

@ -1784,7 +1784,7 @@ fn structInitExpr(
while (it.next()) |entry| { while (it.next()) |entry| {
const record = entry.value_ptr.*; const record = entry.value_ptr.*;
if (record.items.len > 1) { if (record.items.len > 1) {
var error_notes = std.ArrayList(u32).init(astgen.arena); var error_notes = std.array_list.Managed(u32).init(astgen.arena);
for (record.items[1..]) |duplicate| { for (record.items[1..]) |duplicate| {
try error_notes.append(try astgen.errNoteTok(duplicate, "duplicate name here", .{})); try error_notes.append(try astgen.errNoteTok(duplicate, "duplicate name here", .{}));

View File

@ -89,8 +89,8 @@ pub fn detect(
} }
fn detectFromInstallation(arena: Allocator, target: *const std.Target, lci: *const LibCInstallation) !LibCDirs { fn detectFromInstallation(arena: Allocator, target: *const std.Target, lci: *const LibCInstallation) !LibCDirs {
var list = try std.ArrayList([]const u8).initCapacity(arena, 5); var list = try std.array_list.Managed([]const u8).initCapacity(arena, 5);
var framework_list = std.ArrayList([]const u8).init(arena); var framework_list = std.array_list.Managed([]const u8).init(arena);
list.appendAssumeCapacity(lci.include_dir.?); list.appendAssumeCapacity(lci.include_dir.?);

View File

@ -250,7 +250,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, args: FindNativeOptions) F
const dev_null = if (is_windows) "nul" else "/dev/null"; const dev_null = if (is_windows) "nul" else "/dev/null";
var argv = std.ArrayList([]const u8).init(allocator); var argv = std.array_list.Managed([]const u8).init(allocator);
defer argv.deinit(); defer argv.deinit();
try appendCcExe(&argv, skip_cc_env_var); try appendCcExe(&argv, skip_cc_env_var);
@ -294,7 +294,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, args: FindNativeOptions) F
} }
var it = std.mem.tokenizeAny(u8, run_res.stderr, "\n\r"); var it = std.mem.tokenizeAny(u8, run_res.stderr, "\n\r");
var search_paths = std.ArrayList([]const u8).init(allocator); var search_paths = std.array_list.Managed([]const u8).init(allocator);
defer search_paths.deinit(); defer search_paths.deinit();
while (it.next()) |line| { while (it.next()) |line| {
if (line.len != 0 and line[0] == ' ') { if (line.len != 0 and line[0] == ' ') {
@ -365,7 +365,7 @@ fn findNativeIncludeDirWindows(
var install_buf: [2]std.zig.WindowsSdk.Installation = undefined; var install_buf: [2]std.zig.WindowsSdk.Installation = undefined;
const installs = fillInstallations(&install_buf, sdk); const installs = fillInstallations(&install_buf, sdk);
var result_buf = std.ArrayList(u8).init(allocator); var result_buf = std.array_list.Managed(u8).init(allocator);
defer result_buf.deinit(); defer result_buf.deinit();
for (installs) |install| { for (installs) |install| {
@ -404,7 +404,7 @@ fn findNativeCrtDirWindows(
var install_buf: [2]std.zig.WindowsSdk.Installation = undefined; var install_buf: [2]std.zig.WindowsSdk.Installation = undefined;
const installs = fillInstallations(&install_buf, sdk); const installs = fillInstallations(&install_buf, sdk);
var result_buf = std.ArrayList(u8).init(allocator); var result_buf = std.array_list.Managed(u8).init(allocator);
defer result_buf.deinit(); defer result_buf.deinit();
const arch_sub_dir = switch (args.target.cpu.arch) { const arch_sub_dir = switch (args.target.cpu.arch) {
@ -471,7 +471,7 @@ fn findNativeKernel32LibDir(
var install_buf: [2]std.zig.WindowsSdk.Installation = undefined; var install_buf: [2]std.zig.WindowsSdk.Installation = undefined;
const installs = fillInstallations(&install_buf, sdk); const installs = fillInstallations(&install_buf, sdk);
var result_buf = std.ArrayList(u8).init(allocator); var result_buf = std.array_list.Managed(u8).init(allocator);
defer result_buf.deinit(); defer result_buf.deinit();
const arch_sub_dir = switch (args.target.cpu.arch) { const arch_sub_dir = switch (args.target.cpu.arch) {
@ -578,7 +578,7 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 {
break :blk false; break :blk false;
}; };
var argv = std.ArrayList([]const u8).init(allocator); var argv = std.array_list.Managed([]const u8).init(allocator);
defer argv.deinit(); defer argv.deinit();
const arg1 = try std.fmt.allocPrint(allocator, "-print-file-name={s}", .{args.search_basename}); const arg1 = try std.fmt.allocPrint(allocator, "-print-file-name={s}", .{args.search_basename});
@ -671,7 +671,7 @@ fn fillInstallations(
const inf_loop_env_key = "ZIG_IS_DETECTING_LIBC_PATHS"; const inf_loop_env_key = "ZIG_IS_DETECTING_LIBC_PATHS";
fn appendCcExe(args: *std.ArrayList([]const u8), skip_cc_env_var: bool) !void { fn appendCcExe(args: *std.array_list.Managed([]const u8), skip_cc_env_var: bool) !void {
const default_cc_exe = if (is_windows) "cc.exe" else "cc"; const default_cc_exe = if (is_windows) "cc.exe" else "cc";
try args.ensureUnusedCapacity(1); try args.ensureUnusedCapacity(1);
if (skip_cc_env_var) { if (skip_cc_env_var) {

View File

@ -92,8 +92,8 @@ fn iterateAndFilterByVersion(
std.mem.order(u8, lhs.build, rhs.build); std.mem.order(u8, lhs.build, rhs.build);
} }
}; };
var versions = std.ArrayList(Version).init(allocator); var versions = std.array_list.Managed(Version).init(allocator);
var dirs = std.ArrayList([]const u8).init(allocator); var dirs = std.array_list.Managed([]const u8).init(allocator);
defer { defer {
versions.deinit(); versions.deinit();
for (dirs.items) |filtered_dir| allocator.free(filtered_dir); for (dirs.items) |filtered_dir| allocator.free(filtered_dir);
@ -450,7 +450,7 @@ pub const Installation = struct {
return error.PathTooLong; return error.PathTooLong;
} }
var path = std.ArrayList(u8).fromOwnedSlice(allocator, path_maybe_with_trailing_slash); var path = std.array_list.Managed(u8).fromOwnedSlice(allocator, path_maybe_with_trailing_slash);
errdefer path.deinit(); errdefer path.deinit();
// String might contain trailing slash, so trim it here // String might contain trailing slash, so trim it here
@ -522,7 +522,7 @@ pub const Installation = struct {
return error.PathTooLong; return error.PathTooLong;
} }
var path = std.ArrayList(u8).fromOwnedSlice(allocator, path_maybe_with_trailing_slash); var path = std.array_list.Managed(u8).fromOwnedSlice(allocator, path_maybe_with_trailing_slash);
errdefer path.deinit(); errdefer path.deinit();
// String might contain trailing slash, so trim it here // String might contain trailing slash, so trim it here
@ -548,7 +548,7 @@ pub const Installation = struct {
return error.VersionTooLong; return error.VersionTooLong;
} }
var version = std.ArrayList(u8).fromOwnedSlice(allocator, version_without_0); var version = std.array_list.Managed(u8).fromOwnedSlice(allocator, version_without_0);
errdefer version.deinit(); errdefer version.deinit();
try version.appendSlice(".0"); try version.appendSlice(".0");
@ -802,7 +802,7 @@ const MsvcLibDir = struct {
} }
fn libDirFromInstallationPath(allocator: std.mem.Allocator, installation_path: []const u8, arch: std.Target.Cpu.Arch) error{ OutOfMemory, PathNotFound }![]const u8 { fn libDirFromInstallationPath(allocator: std.mem.Allocator, installation_path: []const u8, arch: std.Target.Cpu.Arch) error{ OutOfMemory, PathNotFound }![]const u8 {
var lib_dir_buf = try std.ArrayList(u8).initCapacity(allocator, installation_path.len + 64); var lib_dir_buf = try std.array_list.Managed(u8).initCapacity(allocator, installation_path.len + 64);
errdefer lib_dir_buf.deinit(); errdefer lib_dir_buf.deinit();
lib_dir_buf.appendSliceAssumeCapacity(installation_path); lib_dir_buf.appendSliceAssumeCapacity(installation_path);
@ -897,7 +897,7 @@ const MsvcLibDir = struct {
return error.PathNotFound; return error.PathNotFound;
} }
var msvc_dir = std.ArrayList(u8).fromOwnedSlice(allocator, msvc_include_dir_maybe_with_trailing_slash); var msvc_dir = std.array_list.Managed(u8).fromOwnedSlice(allocator, msvc_include_dir_maybe_with_trailing_slash);
errdefer msvc_dir.deinit(); errdefer msvc_dir.deinit();
// String might contain trailing slash, so trim it here // String might contain trailing slash, so trim it here
@ -929,7 +929,7 @@ const MsvcLibDir = struct {
} }
fn findViaVs7Key(allocator: std.mem.Allocator, arch: std.Target.Cpu.Arch) error{ OutOfMemory, PathNotFound }![]const u8 { fn findViaVs7Key(allocator: std.mem.Allocator, arch: std.Target.Cpu.Arch) error{ OutOfMemory, PathNotFound }![]const u8 {
var base_path: std.ArrayList(u8) = base_path: { var base_path: std.array_list.Managed(u8) = base_path: {
try_env: { try_env: {
var env_map = std.process.getEnvMap(allocator) catch |err| switch (err) { var env_map = std.process.getEnvMap(allocator) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory, error.OutOfMemory => return error.OutOfMemory,
@ -940,7 +940,7 @@ const MsvcLibDir = struct {
if (env_map.get("VS140COMNTOOLS")) |VS140COMNTOOLS| { if (env_map.get("VS140COMNTOOLS")) |VS140COMNTOOLS| {
if (VS140COMNTOOLS.len < "C:\\Common7\\Tools".len) break :try_env; if (VS140COMNTOOLS.len < "C:\\Common7\\Tools".len) break :try_env;
if (!std.fs.path.isAbsolute(VS140COMNTOOLS)) break :try_env; if (!std.fs.path.isAbsolute(VS140COMNTOOLS)) break :try_env;
var list = std.ArrayList(u8).init(allocator); var list = std.array_list.Managed(u8).init(allocator);
errdefer list.deinit(); errdefer list.deinit();
try list.appendSlice(VS140COMNTOOLS); // C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools try list.appendSlice(VS140COMNTOOLS); // C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools
@ -964,7 +964,7 @@ const MsvcLibDir = struct {
break :try_vs7_key; break :try_vs7_key;
} }
var path = std.ArrayList(u8).fromOwnedSlice(allocator, path_maybe_with_trailing_slash); var path = std.array_list.Managed(u8).fromOwnedSlice(allocator, path_maybe_with_trailing_slash);
errdefer path.deinit(); errdefer path.deinit();
// String might contain trailing slash, so trim it here // String might contain trailing slash, so trim it here

View File

@ -60,7 +60,7 @@ pub const Record = struct {
blob: []const u8, blob: []const u8,
fn toOwnedAbbrev(record: Record, allocator: std.mem.Allocator) !Abbrev { fn toOwnedAbbrev(record: Record, allocator: std.mem.Allocator) !Abbrev {
var operands = std.ArrayList(Abbrev.Operand).init(allocator); var operands = std.array_list.Managed(Abbrev.Operand).init(allocator);
defer operands.deinit(); defer operands.deinit();
assert(record.id == Abbrev.Builtin.define_abbrev.toRecordId()); assert(record.id == Abbrev.Builtin.define_abbrev.toRecordId());
@ -194,8 +194,8 @@ fn nextRecord(bc: *BitcodeReader) !?Record {
defer bc.record_arena = record_arena.state; defer bc.record_arena = record_arena.state;
_ = record_arena.reset(.retain_capacity); _ = record_arena.reset(.retain_capacity);
var operands = try std.ArrayList(u64).initCapacity(record_arena.allocator(), abbrev.operands.len); var operands = try std.array_list.Managed(u64).initCapacity(record_arena.allocator(), abbrev.operands.len);
var blob = std.ArrayList(u8).init(record_arena.allocator()); var blob = std.array_list.Managed(u8).init(record_arena.allocator());
for (abbrev.operands, 0..) |abbrev_operand, abbrev_operand_i| switch (abbrev_operand) { for (abbrev.operands, 0..) |abbrev_operand, abbrev_operand_i| switch (abbrev_operand) {
.literal => |value| operands.appendAssumeCapacity(value), .literal => |value| operands.appendAssumeCapacity(value),
.encoding => |abbrev_encoding| switch (abbrev_encoding) { .encoding => |abbrev_encoding| switch (abbrev_encoding) {

View File

@ -9107,7 +9107,7 @@ pub fn getIntrinsic(
var attributes: struct { var attributes: struct {
builder: *Builder, builder: *Builder,
list: std.ArrayList(Attribute.Index), list: std.array_list.Managed(Attribute.Index),
fn deinit(state: *@This()) void { fn deinit(state: *@This()) void {
state.list.deinit(); state.list.deinit();
@ -9120,7 +9120,7 @@ pub fn getIntrinsic(
item.* = try state.builder.attr(attribute); item.* = try state.builder.attr(attribute);
return state.builder.attrs(state.list.items); return state.builder.attrs(state.list.items);
} }
} = .{ .builder = self, .list = std.ArrayList(Attribute.Index).init(allocator) }; } = .{ .builder = self, .list = std.array_list.Managed(Attribute.Index).init(allocator) };
defer attributes.deinit(); defer attributes.deinit();
var overload_index: usize = 0; var overload_index: usize = 0;

View File

@ -19,7 +19,7 @@ pub fn BitcodeWriter(comptime types: []const type) type {
return struct { return struct {
const BcWriter = @This(); const BcWriter = @This();
buffer: std.ArrayList(u32), buffer: std.array_list.Managed(u32),
bit_buffer: u32 = 0, bit_buffer: u32 = 0,
bit_count: u5 = 0, bit_count: u5 = 0,
@ -31,7 +31,7 @@ pub fn BitcodeWriter(comptime types: []const type) type {
pub fn init(allocator: std.mem.Allocator, widths: [types.len]u16) BcWriter { pub fn init(allocator: std.mem.Allocator, widths: [types.len]u16) BcWriter {
return .{ return .{
.buffer = std.ArrayList(u32).init(allocator), .buffer = std.array_list.Managed(u32).init(allocator),
.widths = widths, .widths = widths,
}; };
} }

View File

@ -40,12 +40,12 @@ pub fn hash(opts: @This()) [std.Build.Cache.bin_digest_len]u8 {
} }
pub fn generate(opts: @This(), allocator: Allocator) Allocator.Error![:0]u8 { pub fn generate(opts: @This(), allocator: Allocator) Allocator.Error![:0]u8 {
var buffer = std.ArrayList(u8).init(allocator); var buffer = std.array_list.Managed(u8).init(allocator);
try append(opts, &buffer); try append(opts, &buffer);
return buffer.toOwnedSliceSentinel(0); return buffer.toOwnedSliceSentinel(0);
} }
pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void { pub fn append(opts: @This(), buffer: *std.array_list.Managed(u8)) Allocator.Error!void {
const target = opts.target; const target = opts.target;
const arch_family_name = @tagName(target.cpu.arch.family()); const arch_family_name = @tagName(target.cpu.arch.family());
const zig_backend = opts.zig_backend; const zig_backend = opts.zig_backend;

View File

@ -3644,10 +3644,10 @@ pub fn saveState(comp: *Compilation) !void {
const gpa = comp.gpa; const gpa = comp.gpa;
var bufs = std.ArrayList([]const u8).init(gpa); var bufs = std.array_list.Managed([]const u8).init(gpa);
defer bufs.deinit(); defer bufs.deinit();
var pt_headers = std.ArrayList(Header.PerThread).init(gpa); var pt_headers = std.array_list.Managed(Header.PerThread).init(gpa);
defer pt_headers.deinit(); defer pt_headers.deinit();
if (comp.zcu) |zcu| { if (comp.zcu) |zcu| {
@ -3865,7 +3865,7 @@ pub fn saveState(comp: *Compilation) !void {
try af.finish(); try af.finish();
} }
fn addBuf(list: *std.ArrayList([]const u8), buf: []const u8) void { fn addBuf(list: *std.array_list.Managed([]const u8), buf: []const u8) void {
if (buf.len == 0) return; if (buf.len == 0) return;
list.appendAssumeCapacity(buf); list.appendAssumeCapacity(buf);
} }
@ -5657,7 +5657,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8, owner_mod: *Package.Module
log.info("C import source: {s}", .{out_h_path}); log.info("C import source: {s}", .{out_h_path});
} }
var argv = std.ArrayList([]const u8).init(comp.gpa); var argv = std.array_list.Managed([]const u8).init(comp.gpa);
defer argv.deinit(); defer argv.deinit();
try argv.append(@tagName(comp.config.c_frontend)); // argv[0] is program name, actual args start at [1] try argv.append(@tagName(comp.config.c_frontend)); // argv[0] is program name, actual args start at [1]
@ -6113,7 +6113,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr
const target = comp.getTarget(); const target = comp.getTarget();
const o_ext = target.ofmt.fileExt(target.cpu.arch); const o_ext = target.ofmt.fileExt(target.cpu.arch);
const digest = if (!comp.disable_c_depfile and try man.hit()) man.final() else blk: { const digest = if (!comp.disable_c_depfile and try man.hit()) man.final() else blk: {
var argv = std.ArrayList([]const u8).init(gpa); var argv = std.array_list.Managed([]const u8).init(gpa);
defer argv.deinit(); defer argv.deinit();
// In case we are doing passthrough mode, we need to detect -S and -emit-llvm. // In case we are doing passthrough mode, we need to detect -S and -emit-llvm.
@ -6458,7 +6458,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
try o_dir.writeFile(.{ .sub_path = rc_basename, .data = input }); try o_dir.writeFile(.{ .sub_path = rc_basename, .data = input });
var argv = std.ArrayList([]const u8).init(comp.gpa); var argv = std.array_list.Managed([]const u8).init(comp.gpa);
defer argv.deinit(); defer argv.deinit();
try argv.appendSlice(&.{ try argv.appendSlice(&.{
@ -6515,7 +6515,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
// so we need a temporary filename. // so we need a temporary filename.
const out_res_path = try comp.tmpFilePath(arena, res_filename); const out_res_path = try comp.tmpFilePath(arena, res_filename);
var argv = std.ArrayList([]const u8).init(comp.gpa); var argv = std.array_list.Managed([]const u8).init(comp.gpa);
defer argv.deinit(); defer argv.deinit();
const depfile_filename = try std.fmt.allocPrint(arena, "{s}.d.json", .{rc_basename_noext}); const depfile_filename = try std.fmt.allocPrint(arena, "{s}.d.json", .{rc_basename_noext});
@ -6698,7 +6698,7 @@ pub fn tmpFilePath(comp: Compilation, ally: Allocator, suffix: []const u8) error
pub fn addTranslateCCArgs( pub fn addTranslateCCArgs(
comp: *Compilation, comp: *Compilation,
arena: Allocator, arena: Allocator,
argv: *std.ArrayList([]const u8), argv: *std.array_list.Managed([]const u8),
ext: FileExt, ext: FileExt,
out_dep_path: ?[]const u8, out_dep_path: ?[]const u8,
owner_mod: *Package.Module, owner_mod: *Package.Module,
@ -6713,7 +6713,7 @@ pub fn addTranslateCCArgs(
pub fn addCCArgs( pub fn addCCArgs(
comp: *const Compilation, comp: *const Compilation,
arena: Allocator, arena: Allocator,
argv: *std.ArrayList([]const u8), argv: *std.array_list.Managed([]const u8),
ext: FileExt, ext: FileExt,
out_dep_path: ?[]const u8, out_dep_path: ?[]const u8,
mod: *Package.Module, mod: *Package.Module,

View File

@ -173,7 +173,7 @@ pub const JobQueue = struct {
/// Creates the dependencies.zig source code for the build runner to obtain /// Creates the dependencies.zig source code for the build runner to obtain
/// via `@import("@dependencies")`. /// via `@import("@dependencies")`.
pub fn createDependenciesSource(jq: *JobQueue, buf: *std.ArrayList(u8)) Allocator.Error!void { pub fn createDependenciesSource(jq: *JobQueue, buf: *std.array_list.Managed(u8)) Allocator.Error!void {
const keys = jq.table.keys(); const keys = jq.table.keys();
assert(keys.len != 0); // caller should have added the first one assert(keys.len != 0); // caller should have added the first one
@ -285,7 +285,7 @@ pub const JobQueue = struct {
try buf.appendSlice("};\n"); try buf.appendSlice("};\n");
} }
pub fn createEmptyDependenciesSource(buf: *std.ArrayList(u8)) Allocator.Error!void { pub fn createEmptyDependenciesSource(buf: *std.array_list.Managed(u8)) Allocator.Error!void {
try buf.appendSlice( try buf.appendSlice(
\\pub const packages = struct {}; \\pub const packages = struct {};
\\pub const root_deps: []const struct { []const u8, []const u8 } = &.{}; \\pub const root_deps: []const struct { []const u8, []const u8 } = &.{};
@ -1474,10 +1474,10 @@ fn computeHash(f: *Fetch, pkg_path: Cache.Path, filter: Filter) RunError!Compute
const root_dir = pkg_path.root_dir.handle; const root_dir = pkg_path.root_dir.handle;
// Collect all files, recursively, then sort. // Collect all files, recursively, then sort.
var all_files = std.ArrayList(*HashedFile).init(gpa); var all_files = std.array_list.Managed(*HashedFile).init(gpa);
defer all_files.deinit(); defer all_files.deinit();
var deleted_files = std.ArrayList(*DeletedFile).init(gpa); var deleted_files = std.array_list.Managed(*DeletedFile).init(gpa);
defer deleted_files.deinit(); defer deleted_files.deinit();
// Track directories which had any files deleted from them so that empty directories // Track directories which had any files deleted from them so that empty directories

View File

@ -336,8 +336,8 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module {
if (resolved_target.llvm_cpu_features) |x| break :b x; if (resolved_target.llvm_cpu_features) |x| break :b x;
if (!options.global.use_llvm) break :b null; if (!options.global.use_llvm) break :b null;
var buf = std.ArrayList(u8).init(arena); var buf = std.array_list.Managed(u8).init(arena);
var disabled_features = std.ArrayList(u8).init(arena); var disabled_features = std.array_list.Managed(u8).init(arena);
defer disabled_features.deinit(); defer disabled_features.deinit();
// Append disabled features after enabled ones, so that their effects aren't overwritten. // Append disabled features after enabled ones, so that their effects aren't overwritten.

View File

@ -10,7 +10,7 @@ const RangeSet = @This();
const LazySrcLoc = Zcu.LazySrcLoc; const LazySrcLoc = Zcu.LazySrcLoc;
zcu: *Zcu, zcu: *Zcu,
ranges: std.ArrayList(Range), ranges: std.array_list.Managed(Range),
pub const Range = struct { pub const Range = struct {
first: InternPool.Index, first: InternPool.Index,
@ -21,7 +21,7 @@ pub const Range = struct {
pub fn init(allocator: std.mem.Allocator, zcu: *Zcu) RangeSet { pub fn init(allocator: std.mem.Allocator, zcu: *Zcu) RangeSet {
return .{ return .{
.zcu = zcu, .zcu = zcu,
.ranges = std.ArrayList(Range).init(allocator), .ranges = std.array_list.Managed(Range).init(allocator),
}; };
} }

View File

@ -63,7 +63,7 @@ func_index: InternPool.Index,
func_is_naked: bool, func_is_naked: bool,
/// Used to restore the error return trace when returning a non-error from a function. /// Used to restore the error return trace when returning a non-error from a function.
error_return_trace_index_on_fn_entry: Air.Inst.Ref = .none, error_return_trace_index_on_fn_entry: Air.Inst.Ref = .none,
comptime_err_ret_trace: *std.ArrayList(LazySrcLoc), comptime_err_ret_trace: *std.array_list.Managed(LazySrcLoc),
/// When semantic analysis needs to know the return type of the function whose body /// When semantic analysis needs to know the return type of the function whose body
/// is being analyzed, this `Type` should be used instead of going through `func`. /// is being analyzed, this `Type` should be used instead of going through `func`.
/// This will correctly handle the case of a comptime/inline function call of a /// This will correctly handle the case of a comptime/inline function call of a
@ -376,7 +376,7 @@ pub const Block = struct {
/// What mode to generate float operations in, set by @setFloatMode /// What mode to generate float operations in, set by @setFloatMode
float_mode: std.builtin.FloatMode = .strict, float_mode: std.builtin.FloatMode = .strict,
c_import_buf: ?*std.ArrayList(u8) = null, c_import_buf: ?*std.array_list.Managed(u8) = null,
/// If not `null`, this boolean is set when a `dbg_var_ptr`, `dbg_var_val`, or `dbg_arg_inline`. /// If not `null`, this boolean is set when a `dbg_var_ptr`, `dbg_var_val`, or `dbg_arg_inline`.
/// instruction is emitted. It signals that the innermost lexically /// instruction is emitted. It signals that the innermost lexically
@ -3931,7 +3931,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref,
// Whilst constructing our mapping, we will also initialize optional and error union payloads when // Whilst constructing our mapping, we will also initialize optional and error union payloads when
// we encounter the corresponding pointers. For this reason, the ordering of `to_map` matters. // we encounter the corresponding pointers. For this reason, the ordering of `to_map` matters.
var to_map = try std.ArrayList(Air.Inst.Index).initCapacity(sema.arena, stores.len); var to_map = try std.array_list.Managed(Air.Inst.Index).initCapacity(sema.arena, stores.len);
for (stores) |store_inst_idx| { for (stores) |store_inst_idx| {
const store_inst = sema.air_instructions.get(@intFromEnum(store_inst_idx)); const store_inst = sema.air_instructions.get(@intFromEnum(store_inst_idx));
@ -5665,7 +5665,7 @@ fn zirCImport(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileEr
if (!build_options.have_llvm) if (!build_options.have_llvm)
return sema.fail(parent_block, src, "C import unavailable; Zig compiler built without LLVM extensions", .{}); return sema.fail(parent_block, src, "C import unavailable; Zig compiler built without LLVM extensions", .{});
var c_import_buf = std.ArrayList(u8).init(gpa); var c_import_buf = std.array_list.Managed(u8).init(gpa);
defer c_import_buf.deinit(); defer c_import_buf.deinit();
var child_block: Block = .{ var child_block: Block = .{
@ -10701,7 +10701,7 @@ const SwitchProngAnalysis = struct {
const prong_count = field_indices.len - in_mem_coercible.count(); const prong_count = field_indices.len - in_mem_coercible.count();
const estimated_extra = prong_count * 6 + (prong_count / 10); // 2 for Case, 1 item, probably 3 insts; plus hints const estimated_extra = prong_count * 6 + (prong_count / 10); // 2 for Case, 1 item, probably 3 insts; plus hints
var cases_extra = try std.ArrayList(u32).initCapacity(sema.gpa, estimated_extra); var cases_extra = try std.array_list.Managed(u32).initCapacity(sema.gpa, estimated_extra);
defer cases_extra.deinit(); defer cases_extra.deinit();
{ {
@ -17603,7 +17603,7 @@ fn typeInfoDecls(
const declaration_ty = try sema.getBuiltinType(src, .@"Type.Declaration"); const declaration_ty = try sema.getBuiltinType(src, .@"Type.Declaration");
var decl_vals = std.ArrayList(InternPool.Index).init(gpa); var decl_vals = std.array_list.Managed(InternPool.Index).init(gpa);
defer decl_vals.deinit(); defer decl_vals.deinit();
var seen_namespaces = std.AutoHashMap(*Namespace, void).init(gpa); var seen_namespaces = std.AutoHashMap(*Namespace, void).init(gpa);
@ -17645,7 +17645,7 @@ fn typeInfoNamespaceDecls(
sema: *Sema, sema: *Sema,
opt_namespace_index: InternPool.OptionalNamespaceIndex, opt_namespace_index: InternPool.OptionalNamespaceIndex,
declaration_ty: Type, declaration_ty: Type,
decl_vals: *std.ArrayList(InternPool.Index), decl_vals: *std.array_list.Managed(InternPool.Index),
seen_namespaces: *std.AutoHashMap(*Namespace, void), seen_namespaces: *std.AutoHashMap(*Namespace, void),
) !void { ) !void {
const pt = sema.pt; const pt = sema.pt;
@ -29670,7 +29670,7 @@ fn coerceInMemoryAllowedErrorSets(
} }
} }
var missing_error_buf = std.ArrayList(InternPool.NullTerminatedString).init(gpa); var missing_error_buf = std.array_list.Managed(InternPool.NullTerminatedString).init(gpa);
defer missing_error_buf.deinit(); defer missing_error_buf.deinit();
switch (src_ty.toIntern()) { switch (src_ty.toIntern()) {
@ -37151,7 +37151,7 @@ pub fn resolveDeclaredEnum(
var arena: std.heap.ArenaAllocator = .init(gpa); var arena: std.heap.ArenaAllocator = .init(gpa);
defer arena.deinit(); defer arena.deinit();
var comptime_err_ret_trace: std.ArrayList(Zcu.LazySrcLoc) = .init(gpa); var comptime_err_ret_trace: std.array_list.Managed(Zcu.LazySrcLoc) = .init(gpa);
defer comptime_err_ret_trace.deinit(); defer comptime_err_ret_trace.deinit();
var sema: Sema = .{ var sema: Sema = .{

View File

@ -102,7 +102,7 @@ fn bitCastInner(
.arena = sema.arena, .arena = sema.arena,
.skip_bits = skip_bits, .skip_bits = skip_bits,
.remaining_bits = dest_ty.bitSize(zcu), .remaining_bits = dest_ty.bitSize(zcu),
.unpacked = std.ArrayList(InternPool.Index).init(sema.arena), .unpacked = std.array_list.Managed(InternPool.Index).init(sema.arena),
}; };
switch (endian) { switch (endian) {
.little => { .little => {
@ -163,7 +163,7 @@ fn bitCastSpliceInner(
.arena = sema.arena, .arena = sema.arena,
.skip_bits = 0, .skip_bits = 0,
.remaining_bits = splice_offset, .remaining_bits = splice_offset,
.unpacked = std.ArrayList(InternPool.Index).init(sema.arena), .unpacked = std.array_list.Managed(InternPool.Index).init(sema.arena),
}; };
switch (endian) { switch (endian) {
.little => { .little => {
@ -216,7 +216,7 @@ const UnpackValueBits = struct {
skip_bits: u64, skip_bits: u64,
remaining_bits: u64, remaining_bits: u64,
extra_bits: u64 = undefined, extra_bits: u64 = undefined,
unpacked: std.ArrayList(InternPool.Index), unpacked: std.array_list.Managed(InternPool.Index),
fn add(unpack: *UnpackValueBits, val: Value) BitCastError!void { fn add(unpack: *UnpackValueBits, val: Value) BitCastError!void {
const pt = unpack.pt; const pt = unpack.pt;

View File

@ -3805,7 +3805,7 @@ fn resolveStructInner(
var analysis_arena = std.heap.ArenaAllocator.init(gpa); var analysis_arena = std.heap.ArenaAllocator.init(gpa);
defer analysis_arena.deinit(); defer analysis_arena.deinit();
var comptime_err_ret_trace = std.ArrayList(Zcu.LazySrcLoc).init(gpa); var comptime_err_ret_trace = std.array_list.Managed(Zcu.LazySrcLoc).init(gpa);
defer comptime_err_ret_trace.deinit(); defer comptime_err_ret_trace.deinit();
const zir = zcu.namespacePtr(struct_obj.namespace).fileScope(zcu).zir.?; const zir = zcu.namespacePtr(struct_obj.namespace).fileScope(zcu).zir.?;
@ -3864,7 +3864,7 @@ fn resolveUnionInner(
var analysis_arena = std.heap.ArenaAllocator.init(gpa); var analysis_arena = std.heap.ArenaAllocator.init(gpa);
defer analysis_arena.deinit(); defer analysis_arena.deinit();
var comptime_err_ret_trace = std.ArrayList(Zcu.LazySrcLoc).init(gpa); var comptime_err_ret_trace = std.array_list.Managed(Zcu.LazySrcLoc).init(gpa);
defer comptime_err_ret_trace.deinit(); defer comptime_err_ret_trace.deinit();
const zir = zcu.namespacePtr(union_obj.namespace).fileScope(zcu).zir.?; const zir = zcu.namespacePtr(union_obj.namespace).fileScope(zcu).zir.?;

View File

@ -727,7 +727,7 @@ fn analyzeMemoizedState(pt: Zcu.PerThread, stage: InternPool.MemoizedStateStage)
var analysis_arena: std.heap.ArenaAllocator = .init(gpa); var analysis_arena: std.heap.ArenaAllocator = .init(gpa);
defer analysis_arena.deinit(); defer analysis_arena.deinit();
var comptime_err_ret_trace: std.ArrayList(Zcu.LazySrcLoc) = .init(gpa); var comptime_err_ret_trace: std.array_list.Managed(Zcu.LazySrcLoc) = .init(gpa);
defer comptime_err_ret_trace.deinit(); defer comptime_err_ret_trace.deinit();
var sema: Sema = .{ var sema: Sema = .{
@ -870,7 +870,7 @@ fn analyzeComptimeUnit(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu
var analysis_arena: std.heap.ArenaAllocator = .init(gpa); var analysis_arena: std.heap.ArenaAllocator = .init(gpa);
defer analysis_arena.deinit(); defer analysis_arena.deinit();
var comptime_err_ret_trace: std.ArrayList(Zcu.LazySrcLoc) = .init(gpa); var comptime_err_ret_trace: std.array_list.Managed(Zcu.LazySrcLoc) = .init(gpa);
defer comptime_err_ret_trace.deinit(); defer comptime_err_ret_trace.deinit();
var sema: Sema = .{ var sema: Sema = .{
@ -1097,7 +1097,7 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr
var analysis_arena: std.heap.ArenaAllocator = .init(gpa); var analysis_arena: std.heap.ArenaAllocator = .init(gpa);
defer analysis_arena.deinit(); defer analysis_arena.deinit();
var comptime_err_ret_trace: std.ArrayList(Zcu.LazySrcLoc) = .init(gpa); var comptime_err_ret_trace: std.array_list.Managed(Zcu.LazySrcLoc) = .init(gpa);
defer comptime_err_ret_trace.deinit(); defer comptime_err_ret_trace.deinit();
var sema: Sema = .{ var sema: Sema = .{
@ -1471,7 +1471,7 @@ fn analyzeNavType(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileEr
var analysis_arena: std.heap.ArenaAllocator = .init(gpa); var analysis_arena: std.heap.ArenaAllocator = .init(gpa);
defer analysis_arena.deinit(); defer analysis_arena.deinit();
var comptime_err_ret_trace: std.ArrayList(Zcu.LazySrcLoc) = .init(gpa); var comptime_err_ret_trace: std.array_list.Managed(Zcu.LazySrcLoc) = .init(gpa);
defer comptime_err_ret_trace.deinit(); defer comptime_err_ret_trace.deinit();
var sema: Sema = .{ var sema: Sema = .{
@ -2807,7 +2807,7 @@ fn analyzeFnBodyInner(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaE
var analysis_arena = std.heap.ArenaAllocator.init(gpa); var analysis_arena = std.heap.ArenaAllocator.init(gpa);
defer analysis_arena.deinit(); defer analysis_arena.deinit();
var comptime_err_ret_trace = std.ArrayList(Zcu.LazySrcLoc).init(gpa); var comptime_err_ret_trace = std.array_list.Managed(Zcu.LazySrcLoc).init(gpa);
defer comptime_err_ret_trace.deinit(); defer comptime_err_ret_trace.deinit();
// In the case of a generic function instance, this is the type of the // In the case of a generic function instance, this is the type of the

View File

@ -101,7 +101,7 @@ reused_operands: std.StaticBitSet(Air.Liveness.bpi - 1) = undefined,
/// within different branches. Special consideration is needed when a branch /// within different branches. Special consideration is needed when a branch
/// joins with its parent, to make sure all instructions have the same MCValue /// joins with its parent, to make sure all instructions have the same MCValue
/// across each runtime branch upon joining. /// across each runtime branch upon joining.
branch_stack: *std.ArrayList(Branch), branch_stack: *std.array_list.Managed(Branch),
// Currently set vector properties, null means they haven't been set yet in the function. // Currently set vector properties, null means they haven't been set yet in the function.
avl: ?u64, avl: ?u64,
@ -674,7 +674,7 @@ fn restoreState(func: *Func, state: State, deaths: []const Air.Inst.Index, compt
var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) = var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =
if (opts.update_tracking) {} else std.heap.stackFallback(@sizeOf(ExpectedContents), func.gpa); if (opts.update_tracking) {} else std.heap.stackFallback(@sizeOf(ExpectedContents), func.gpa);
var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity( var reg_locks = if (opts.update_tracking) {} else try std.array_list.Managed(RegisterLock).initCapacity(
stack.get(), stack.get(),
@typeInfo(ExpectedContents).array.len, @typeInfo(ExpectedContents).array.len,
); );
@ -753,7 +753,7 @@ pub fn generate(
const fn_type = Type.fromInterned(func.ty); const fn_type = Type.fromInterned(func.ty);
const mod = zcu.navFileScope(func.owner_nav).mod.?; const mod = zcu.navFileScope(func.owner_nav).mod.?;
var branch_stack = std.ArrayList(Branch).init(gpa); var branch_stack = std.array_list.Managed(Branch).init(gpa);
defer { defer {
assert(branch_stack.items.len == 1); assert(branch_stack.items.len == 1);
branch_stack.items[0].deinit(gpa); branch_stack.items[0].deinit(gpa);
@ -4883,7 +4883,7 @@ fn genCall(
stack_frame_align.* = stack_frame_align.max(needed_call_frame.abi_align); stack_frame_align.* = stack_frame_align.max(needed_call_frame.abi_align);
} }
var reg_locks = std.ArrayList(?RegisterLock).init(allocator); var reg_locks = std.array_list.Managed(?RegisterLock).init(allocator);
defer reg_locks.deinit(); defer reg_locks.deinit();
try reg_locks.ensureTotalCapacity(8); try reg_locks.ensureTotalCapacity(8);
defer for (reg_locks.items) |reg_lock| if (reg_lock) |lock| func.register_manager.unlockReg(lock); defer for (reg_locks.items) |reg_lock| if (reg_lock) |lock| func.register_manager.unlockReg(lock);
@ -6056,7 +6056,7 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {
extra_i += inputs.len; extra_i += inputs.len;
var result: MCValue = .none; var result: MCValue = .none;
var args = std.ArrayList(MCValue).init(func.gpa); var args = std.array_list.Managed(MCValue).init(func.gpa);
try args.ensureTotalCapacity(outputs.len + inputs.len); try args.ensureTotalCapacity(outputs.len + inputs.len);
defer { defer {
for (args.items) |arg| if (arg.getReg()) |reg| func.register_manager.unlockReg(.{ for (args.items) |arg| if (arg.getReg()) |reg| func.register_manager.unlockReg(.{

View File

@ -88,7 +88,7 @@ reused_operands: std.StaticBitSet(Air.Liveness.bpi - 1) = undefined,
/// within different branches. Special consideration is needed when a branch /// within different branches. Special consideration is needed when a branch
/// joins with its parent, to make sure all instructions have the same MCValue /// joins with its parent, to make sure all instructions have the same MCValue
/// across each runtime branch upon joining. /// across each runtime branch upon joining.
branch_stack: *std.ArrayList(Branch), branch_stack: *std.array_list.Managed(Branch),
// Key is the block instruction // Key is the block instruction
blocks: std.AutoHashMapUnmanaged(Air.Inst.Index, BlockData) = .empty, blocks: std.AutoHashMapUnmanaged(Air.Inst.Index, BlockData) = .empty,
@ -276,7 +276,7 @@ pub fn generate(
const file_scope = zcu.navFileScope(func.owner_nav); const file_scope = zcu.navFileScope(func.owner_nav);
const target = &file_scope.mod.?.resolved_target.result; const target = &file_scope.mod.?.resolved_target.result;
var branch_stack = std.ArrayList(Branch).init(gpa); var branch_stack = std.array_list.Managed(Branch).init(gpa);
defer { defer {
assert(branch_stack.items.len == 1); assert(branch_stack.items.len == 1);
branch_stack.items[0].deinit(gpa); branch_stack.items[0].deinit(gpa);

View File

@ -1301,7 +1301,7 @@ fn resolveCallingConventionValues(
}; };
if (cc == .naked) return result; if (cc == .naked) return result;
var args = std.ArrayList(WValue).init(gpa); var args = std.array_list.Managed(WValue).init(gpa);
defer args.deinit(); defer args.deinit();
// Check if we store the result as a pointer to the stack rather than // Check if we store the result as a pointer to the stack rather than
@ -7132,7 +7132,7 @@ fn airErrorSetHasValue(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const result = try cg.allocLocal(Type.bool); const result = try cg.allocLocal(Type.bool);
const names = error_set_ty.errorSetNames(zcu); const names = error_set_ty.errorSetNames(zcu);
var values = try std.ArrayList(u32).initCapacity(cg.gpa, names.len); var values = try std.array_list.Managed(u32).initCapacity(cg.gpa, names.len);
defer values.deinit(); defer values.deinit();
var lowest: ?u32 = null; var lowest: ?u32 = null;

View File

@ -169359,7 +169359,7 @@ fn restoreState(self: *CodeGen, state: State, deaths: []const Air.Inst.Index, co
var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) = var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =
if (opts.update_tracking) {} else std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa); if (opts.update_tracking) {} else std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa);
var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity( var reg_locks = if (opts.update_tracking) {} else try std.array_list.Managed(RegisterLock).initCapacity(
stack.get(), stack.get(),
@typeInfo(ExpectedContents).array.len, @typeInfo(ExpectedContents).array.len,
); );
@ -178175,7 +178175,7 @@ fn genCall(self: *CodeGen, info: union(enum) {
const frame_indices = try allocator.alloc(FrameIndex, args.len); const frame_indices = try allocator.alloc(FrameIndex, args.len);
defer allocator.free(frame_indices); defer allocator.free(frame_indices);
var reg_locks: std.ArrayList(?RegisterLock) = .init(allocator); var reg_locks: std.array_list.Managed(?RegisterLock) = .init(allocator);
defer reg_locks.deinit(); defer reg_locks.deinit();
try reg_locks.ensureTotalCapacity(16); try reg_locks.ensureTotalCapacity(16);
defer for (reg_locks.items) |reg_lock| if (reg_lock) |lock| self.register_manager.unlockReg(lock); defer for (reg_locks.items) |reg_lock| if (reg_lock) |lock| self.register_manager.unlockReg(lock);
@ -179786,7 +179786,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
extra_i += inputs.len; extra_i += inputs.len;
var result: MCValue = .none; var result: MCValue = .none;
var args: std.ArrayList(MCValue) = .init(self.gpa); var args: std.array_list.Managed(MCValue) = .init(self.gpa);
try args.ensureTotalCapacity(outputs.len + inputs.len); try args.ensureTotalCapacity(outputs.len + inputs.len);
defer { defer {
for (args.items) |arg| if (arg.getReg()) |reg| self.register_manager.unlockReg(.{ for (args.items) |arg| if (arg.getReg()) |reg| self.register_manager.unlockReg(.{

View File

@ -1216,7 +1216,7 @@ const TestEncode = struct {
}; };
test "encode" { test "encode" {
var buf = std.ArrayList(u8).init(testing.allocator); var buf = std.array_list.Managed(u8).init(testing.allocator);
defer buf.deinit(); defer buf.deinit();
const inst: Instruction = try .new(.none, .mov, &.{ const inst: Instruction = try .new(.none, .mov, &.{
@ -2647,7 +2647,7 @@ test "assemble" {
// zig fmt: on // zig fmt: on
var as = Assembler.init(input); var as = Assembler.init(input);
var output = std.ArrayList(u8).init(testing.allocator); var output = std.array_list.Managed(u8).init(testing.allocator);
defer output.deinit(); defer output.deinit();
try as.assemble(output.writer()); try as.assemble(output.writer());
try expectEqualHexStrings(expected, output.items, input); try expectEqualHexStrings(expected, output.items, input);
@ -2691,7 +2691,7 @@ test "assemble - Jcc" {
const input = @tagName(mnemonic[0]) ++ " 0x0"; const input = @tagName(mnemonic[0]) ++ " 0x0";
const expected = [_]u8{ 0x0f, mnemonic[1], 0x0, 0x0, 0x0, 0x0 }; const expected = [_]u8{ 0x0f, mnemonic[1], 0x0, 0x0, 0x0, 0x0 };
var as = Assembler.init(input); var as = Assembler.init(input);
var output = std.ArrayList(u8).init(testing.allocator); var output = std.array_list.Managed(u8).init(testing.allocator);
defer output.deinit(); defer output.deinit();
try as.assemble(output.writer()); try as.assemble(output.writer());
try expectEqualHexStrings(&expected, output.items, input); try expectEqualHexStrings(&expected, output.items, input);
@ -2736,7 +2736,7 @@ test "assemble - SETcc" {
const input = @tagName(mnemonic[0]) ++ " al"; const input = @tagName(mnemonic[0]) ++ " al";
const expected = [_]u8{ 0x0f, mnemonic[1], 0xC0 }; const expected = [_]u8{ 0x0f, mnemonic[1], 0xC0 };
var as = Assembler.init(input); var as = Assembler.init(input);
var output = std.ArrayList(u8).init(testing.allocator); var output = std.array_list.Managed(u8).init(testing.allocator);
defer output.deinit(); defer output.deinit();
try as.assemble(output.writer()); try as.assemble(output.writer());
try expectEqualHexStrings(&expected, output.items, input); try expectEqualHexStrings(&expected, output.items, input);
@ -2781,7 +2781,7 @@ test "assemble - CMOVcc" {
const input = @tagName(mnemonic[0]) ++ " rax, rbx"; const input = @tagName(mnemonic[0]) ++ " rax, rbx";
const expected = [_]u8{ 0x48, 0x0f, mnemonic[1], 0xC3 }; const expected = [_]u8{ 0x48, 0x0f, mnemonic[1], 0xC3 };
var as = Assembler.init(input); var as = Assembler.init(input);
var output = std.ArrayList(u8).init(testing.allocator); var output = std.array_list.Managed(u8).init(testing.allocator);
defer output.deinit(); defer output.deinit();
try as.assemble(output.writer()); try as.assemble(output.writer());
try expectEqualHexStrings(&expected, output.items, input); try expectEqualHexStrings(&expected, output.items, input);

View File

@ -53,7 +53,7 @@ fn subArchName(target: *const std.Target, comptime family: std.Target.Cpu.Arch.F
} }
pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8 { pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8 {
var llvm_triple = std.ArrayList(u8).init(allocator); var llvm_triple = std.array_list.Managed(u8).init(allocator);
defer llvm_triple.deinit(); defer llvm_triple.deinit();
const llvm_arch = switch (target.cpu.arch) { const llvm_arch = switch (target.cpu.arch) {
@ -820,7 +820,7 @@ pub const Object = struct {
} }
{ {
var module_flags = try std.ArrayList(Builder.Metadata).initCapacity(o.gpa, 8); var module_flags = try std.array_list.Managed(Builder.Metadata).initCapacity(o.gpa, 8);
defer module_flags.deinit(); defer module_flags.deinit();
const behavior_error = try o.builder.metadataConstant(try o.builder.intConst(.i32, 1)); const behavior_error = try o.builder.metadataConstant(try o.builder.intConst(.i32, 1));
@ -2583,7 +2583,7 @@ pub const Object = struct {
.@"fn" => { .@"fn" => {
const fn_info = zcu.typeToFunc(ty).?; const fn_info = zcu.typeToFunc(ty).?;
var debug_param_types = std.ArrayList(Builder.Metadata).init(gpa); var debug_param_types = std.array_list.Managed(Builder.Metadata).init(gpa);
defer debug_param_types.deinit(); defer debug_param_types.deinit();
try debug_param_types.ensureUnusedCapacity(3 + fn_info.param_types.len); try debug_param_types.ensureUnusedCapacity(3 + fn_info.param_types.len);
@ -5254,7 +5254,7 @@ pub const FuncGen = struct {
const target = zcu.getTarget(); const target = zcu.getTarget();
const sret = firstParamSRet(fn_info, zcu, target); const sret = firstParamSRet(fn_info, zcu, target);
var llvm_args = std.ArrayList(Builder.Value).init(self.gpa); var llvm_args = std.array_list.Managed(Builder.Value).init(self.gpa);
defer llvm_args.deinit(); defer llvm_args.deinit();
var attributes: Builder.FunctionAttributes.Wip = .{}; var attributes: Builder.FunctionAttributes.Wip = .{};
@ -7536,7 +7536,7 @@ pub const FuncGen = struct {
const asm_source = std.mem.sliceAsBytes(self.air.extra.items[extra_i..])[0..extra.data.source_len]; const asm_source = std.mem.sliceAsBytes(self.air.extra.items[extra_i..])[0..extra.data.source_len];
// hackety hacks until stage2 has proper inline asm in the frontend. // hackety hacks until stage2 has proper inline asm in the frontend.
var rendered_template = std.ArrayList(u8).init(gpa); var rendered_template = std.array_list.Managed(u8).init(gpa);
defer rendered_template.deinit(); defer rendered_template.deinit();
const State = enum { start, percent, input, modifier }; const State = enum { start, percent, input, modifier };

View File

@ -970,10 +970,10 @@ fn constant(cg: *CodeGen, ty: Type, val: Value, repr: Repr) Error!Id {
return try cg.constInt(backing_ty, @as(u64, @bitCast(limbs))); return try cg.constInt(backing_ty, @as(u64, @bitCast(limbs)));
} }
var types = std.ArrayList(Type).init(gpa); var types = std.array_list.Managed(Type).init(gpa);
defer types.deinit(); defer types.deinit();
var constituents = std.ArrayList(Id).init(gpa); var constituents = std.array_list.Managed(Id).init(gpa);
defer constituents.deinit(); defer constituents.deinit();
var it = struct_type.iterateRuntimeOrder(ip); var it = struct_type.iterateRuntimeOrder(ip);
@ -1519,13 +1519,13 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id {
return try cg.resolveType(.fromInterned(struct_type.backingIntTypeUnordered(ip)), .direct); return try cg.resolveType(.fromInterned(struct_type.backingIntTypeUnordered(ip)), .direct);
} }
var member_types = std.ArrayList(Id).init(gpa); var member_types = std.array_list.Managed(Id).init(gpa);
defer member_types.deinit(); defer member_types.deinit();
var member_names = std.ArrayList([]const u8).init(gpa); var member_names = std.array_list.Managed([]const u8).init(gpa);
defer member_names.deinit(); defer member_names.deinit();
var member_offsets = std.ArrayList(u32).init(gpa); var member_offsets = std.array_list.Managed(u32).init(gpa);
defer member_offsets.deinit(); defer member_offsets.deinit();
var it = struct_type.iterateRuntimeOrder(ip); var it = struct_type.iterateRuntimeOrder(ip);

View File

@ -281,7 +281,7 @@ pub fn addEntryPointDeps(
module: *Module, module: *Module,
decl_index: Decl.Index, decl_index: Decl.Index,
seen: *std.DynamicBitSetUnmanaged, seen: *std.DynamicBitSetUnmanaged,
interface: *std.ArrayList(Id), interface: *std.array_list.Managed(Id),
) !void { ) !void {
const decl = module.declPtr(decl_index); const decl = module.declPtr(decl_index);
const deps = module.decl_deps.items[decl.begin_dep..decl.end_dep]; const deps = module.decl_deps.items[decl.begin_dep..decl.end_dep];
@ -307,7 +307,7 @@ fn entryPoints(module: *Module) !Section {
var entry_points = Section{}; var entry_points = Section{};
errdefer entry_points.deinit(module.gpa); errdefer entry_points.deinit(module.gpa);
var interface = std.ArrayList(Id).init(module.gpa); var interface = std.array_list.Managed(Id).init(module.gpa);
defer interface.deinit(); defer interface.deinit();
var seen = try std.DynamicBitSetUnmanaged.initEmpty(module.gpa, module.decls.items.len); var seen = try std.DynamicBitSetUnmanaged.initEmpty(module.gpa, module.decls.items.len);

View File

@ -46,9 +46,9 @@ pub fn run(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
var check_flag = false; var check_flag = false;
var check_ast_flag = false; var check_ast_flag = false;
var force_zon = false; var force_zon = false;
var input_files = std.ArrayList([]const u8).init(gpa); var input_files = std.array_list.Managed([]const u8).init(gpa);
defer input_files.deinit(); defer input_files.deinit();
var excluded_files = std.ArrayList([]const u8).init(gpa); var excluded_files = std.array_list.Managed([]const u8).init(gpa);
defer excluded_files.deinit(); defer excluded_files.deinit();
{ {

View File

@ -76,7 +76,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
switch (crt_file) { switch (crt_file) {
.scrt1_o => { .scrt1_o => {
var cflags = std.ArrayList([]const u8).init(arena); var cflags = std.array_list.Managed([]const u8).init(arena);
try cflags.appendSlice(&.{ try cflags.appendSlice(&.{
"-O2", "-O2",
"-fno-common", "-fno-common",
@ -89,7 +89,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
try cflags.append("-mlongcall"); try cflags.append("-mlongcall");
} }
var acflags = std.ArrayList([]const u8).init(arena); var acflags = std.array_list.Managed([]const u8).init(arena);
try acflags.appendSlice(&.{ try acflags.appendSlice(&.{
"-DLOCORE", "-DLOCORE",
// See `Compilation.addCCArgs`. // See `Compilation.addCCArgs`.
@ -510,7 +510,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
}; };
{ {
var map_contents = std.ArrayList(u8).init(arena); var map_contents = std.array_list.Managed(u8).init(arena);
for (metadata.all_versions[0 .. target_ver_index + 1]) |ver| { for (metadata.all_versions[0 .. target_ver_index + 1]) |ver| {
try map_contents.writer().print("FBSD_{d}.{d} {{ }};\n", .{ ver.major, ver.minor }); try map_contents.writer().print("FBSD_{d}.{d} {{ }};\n", .{ ver.major, ver.minor });
} }
@ -518,7 +518,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
map_contents.deinit(); map_contents.deinit();
} }
var stubs_asm = std.ArrayList(u8).init(gpa); var stubs_asm = std.array_list.Managed(u8).init(gpa);
defer stubs_asm.deinit(); defer stubs_asm.deinit();
for (libs, 0..) |lib, lib_i| { for (libs, 0..) |lib, lib_i| {
@ -529,7 +529,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
try stubs_writer.writeAll(".text\n"); try stubs_writer.writeAll(".text\n");
var sym_i: usize = 0; var sym_i: usize = 0;
var sym_name_buf = std.ArrayList(u8).init(arena); var sym_name_buf = std.array_list.Managed(u8).init(arena);
var opt_symbol_name: ?[]const u8 = null; var opt_symbol_name: ?[]const u8 = null;
var versions = try std.DynamicBitSetUnmanaged.initEmpty(arena, metadata.all_versions.len); var versions = try std.DynamicBitSetUnmanaged.initEmpty(arena, metadata.all_versions.len);
var weak_linkages = try std.DynamicBitSetUnmanaged.initEmpty(arena, metadata.all_versions.len); var weak_linkages = try std.DynamicBitSetUnmanaged.initEmpty(arena, metadata.all_versions.len);

View File

@ -186,7 +186,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
switch (crt_file) { switch (crt_file) {
.scrt1_o => { .scrt1_o => {
const start_o: Compilation.CSourceFile = blk: { const start_o: Compilation.CSourceFile = blk: {
var args = std.ArrayList([]const u8).init(arena); var args = std.array_list.Managed([]const u8).init(arena);
try add_include_dirs(comp, arena, &args); try add_include_dirs(comp, arena, &args);
try args.appendSlice(&[_][]const u8{ try args.appendSlice(&[_][]const u8{
"-D_LIBC_REENTRANT", "-D_LIBC_REENTRANT",
@ -210,7 +210,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
}; };
}; };
const abi_note_o: Compilation.CSourceFile = blk: { const abi_note_o: Compilation.CSourceFile = blk: {
var args = std.ArrayList([]const u8).init(arena); var args = std.array_list.Managed([]const u8).init(arena);
try args.appendSlice(&[_][]const u8{ try args.appendSlice(&[_][]const u8{
"-I", "-I",
try lib_path(comp, arena, lib_libc_glibc ++ "csu"), try lib_path(comp, arena, lib_libc_glibc ++ "csu"),
@ -306,7 +306,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
for (deps) |dep| { for (deps) |dep| {
if (!dep.include) continue; if (!dep.include) continue;
var args = std.ArrayList([]const u8).init(arena); var args = std.array_list.Managed([]const u8).init(arena);
try args.appendSlice(&[_][]const u8{ try args.appendSlice(&[_][]const u8{
"-std=gnu11", "-std=gnu11",
"-fgnu89-inline", "-fgnu89-inline",
@ -364,7 +364,7 @@ fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![
const s = path.sep_str; const s = path.sep_str;
var result = std.ArrayList(u8).init(arena); var result = std.array_list.Managed(u8).init(arena);
try result.appendSlice(comp.dirs.zig_lib.path orelse "."); try result.appendSlice(comp.dirs.zig_lib.path orelse ".");
try result.appendSlice(s ++ "libc" ++ s ++ "glibc" ++ s ++ "sysdeps" ++ s); try result.appendSlice(s ++ "libc" ++ s ++ "glibc" ++ s ++ "sysdeps" ++ s);
if (is_sparc) { if (is_sparc) {
@ -408,7 +408,7 @@ fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![
return result.items; return result.items;
} }
fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void { fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.array_list.Managed([]const u8)) error{OutOfMemory}!void {
const target = comp.getTarget(); const target = comp.getTarget();
const opt_nptl: ?[]const u8 = if (target.os.tag == .linux) "nptl" else "htl"; const opt_nptl: ?[]const u8 = if (target.os.tag == .linux) "nptl" else "htl";
@ -484,7 +484,7 @@ fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([
fn add_include_dirs_arch( fn add_include_dirs_arch(
arena: Allocator, arena: Allocator,
args: *std.ArrayList([]const u8), args: *std.array_list.Managed([]const u8),
target: *const std.Target, target: *const std.Target,
opt_nptl: ?[]const u8, opt_nptl: ?[]const u8,
dir: []const u8, dir: []const u8,
@ -749,7 +749,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
}; };
{ {
var map_contents = std.ArrayList(u8).init(arena); var map_contents = std.array_list.Managed(u8).init(arena);
for (metadata.all_versions[0 .. target_ver_index + 1]) |ver| { for (metadata.all_versions[0 .. target_ver_index + 1]) |ver| {
if (ver.patch == 0) { if (ver.patch == 0) {
try map_contents.writer().print("GLIBC_{d}.{d} {{ }};\n", .{ ver.major, ver.minor }); try map_contents.writer().print("GLIBC_{d}.{d} {{ }};\n", .{ ver.major, ver.minor });
@ -761,7 +761,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
map_contents.deinit(); // The most recent allocation of an arena can be freed :) map_contents.deinit(); // The most recent allocation of an arena can be freed :)
} }
var stubs_asm = std.ArrayList(u8).init(gpa); var stubs_asm = std.array_list.Managed(u8).init(gpa);
defer stubs_asm.deinit(); defer stubs_asm.deinit();
for (libs, 0..) |lib, lib_i| { for (libs, 0..) |lib, lib_i| {
@ -773,7 +773,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
try stubs_asm.appendSlice(".text\n"); try stubs_asm.appendSlice(".text\n");
var sym_i: usize = 0; var sym_i: usize = 0;
var sym_name_buf = std.ArrayList(u8).init(arena); var sym_name_buf = std.array_list.Managed(u8).init(arena);
var opt_symbol_name: ?[]const u8 = null; var opt_symbol_name: ?[]const u8 = null;
var versions_buffer: [32]u8 = undefined; var versions_buffer: [32]u8 = undefined;
var versions_len: usize = undefined; var versions_len: usize = undefined;

View File

@ -190,7 +190,7 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
else else
&libcxx_base_files; &libcxx_base_files;
var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxx_files.len); var c_source_files = try std.array_list.Managed(Compilation.CSourceFile).initCapacity(arena, libcxx_files.len);
for (libcxx_files) |cxx_src| { for (libcxx_files) |cxx_src| {
// These don't compile on WASI due to e.g. `fchmod` usage. // These don't compile on WASI due to e.g. `fchmod` usage.
@ -201,7 +201,7 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
if (std.mem.startsWith(u8, cxx_src, "src/support/ibm/") and target.os.tag != .zos) if (std.mem.startsWith(u8, cxx_src, "src/support/ibm/") and target.os.tag != .zos)
continue; continue;
var cflags = std.ArrayList([]const u8).init(arena); var cflags = std.array_list.Managed([]const u8).init(arena);
try addCxxArgs(comp, arena, &cflags); try addCxxArgs(comp, arena, &cflags);
@ -233,7 +233,7 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
// These depend on only the zig lib directory file path, which is // These depend on only the zig lib directory file path, which is
// purposefully either in the cache or not in the cache. The decision // purposefully either in the cache or not in the cache. The decision
// should not be overridden here. // should not be overridden here.
var cache_exempt_flags = std.ArrayList([]const u8).init(arena); var cache_exempt_flags = std.array_list.Managed([]const u8).init(arena);
try cache_exempt_flags.append("-I"); try cache_exempt_flags.append("-I");
try cache_exempt_flags.append(cxx_include_path); try cache_exempt_flags.append(cxx_include_path);
@ -385,7 +385,7 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
return error.AlreadyReported; return error.AlreadyReported;
}; };
var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxxabi_files.len); var c_source_files = try std.array_list.Managed(Compilation.CSourceFile).initCapacity(arena, libcxxabi_files.len);
for (libcxxabi_files) |cxxabi_src| { for (libcxxabi_files) |cxxabi_src| {
if (!comp.config.any_non_single_threaded and std.mem.startsWith(u8, cxxabi_src, "src/cxa_thread_atexit.cpp")) if (!comp.config.any_non_single_threaded and std.mem.startsWith(u8, cxxabi_src, "src/cxa_thread_atexit.cpp"))
@ -394,7 +394,7 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
(std.mem.eql(u8, cxxabi_src, "src/cxa_exception.cpp") or std.mem.eql(u8, cxxabi_src, "src/cxa_personality.cpp"))) (std.mem.eql(u8, cxxabi_src, "src/cxa_exception.cpp") or std.mem.eql(u8, cxxabi_src, "src/cxa_personality.cpp")))
continue; continue;
var cflags = std.ArrayList([]const u8).init(arena); var cflags = std.array_list.Managed([]const u8).init(arena);
try addCxxArgs(comp, arena, &cflags); try addCxxArgs(comp, arena, &cflags);
@ -425,7 +425,7 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
// These depend on only the zig lib directory file path, which is // These depend on only the zig lib directory file path, which is
// purposefully either in the cache or not in the cache. The decision // purposefully either in the cache or not in the cache. The decision
// should not be overridden here. // should not be overridden here.
var cache_exempt_flags = std.ArrayList([]const u8).init(arena); var cache_exempt_flags = std.array_list.Managed([]const u8).init(arena);
try cache_exempt_flags.append("-I"); try cache_exempt_flags.append("-I");
try cache_exempt_flags.append(cxxabi_include_path); try cache_exempt_flags.append(cxxabi_include_path);
@ -497,7 +497,7 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
pub fn addCxxArgs( pub fn addCxxArgs(
comp: *const Compilation, comp: *const Compilation,
arena: std.mem.Allocator, arena: std.mem.Allocator,
cflags: *std.ArrayList([]const u8), cflags: *std.array_list.Managed([]const u8),
) error{OutOfMemory}!void { ) error{OutOfMemory}!void {
const target = comp.getTarget(); const target = comp.getTarget();
const optimize_mode = comp.compilerRtOptMode(); const optimize_mode = comp.compilerRtOptMode();

View File

@ -113,12 +113,12 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
return error.AlreadyReported; return error.AlreadyReported;
}; };
var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena); var c_source_files = std.array_list.Managed(Compilation.CSourceFile).init(arena);
try c_source_files.ensureUnusedCapacity(tsan_sources.len); try c_source_files.ensureUnusedCapacity(tsan_sources.len);
const tsan_include_path = try comp.dirs.zig_lib.join(arena, &.{"libtsan"}); const tsan_include_path = try comp.dirs.zig_lib.join(arena, &.{"libtsan"});
for (tsan_sources) |tsan_src| { for (tsan_sources) |tsan_src| {
var cflags = std.ArrayList([]const u8).init(arena); var cflags = std.array_list.Managed([]const u8).init(arena);
try cflags.append("-I"); try cflags.append("-I");
try cflags.append(tsan_include_path); try cflags.append(tsan_include_path);
@ -139,7 +139,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
}; };
try c_source_files.ensureUnusedCapacity(platform_tsan_sources.len); try c_source_files.ensureUnusedCapacity(platform_tsan_sources.len);
for (platform_tsan_sources) |tsan_src| { for (platform_tsan_sources) |tsan_src| {
var cflags = std.ArrayList([]const u8).init(arena); var cflags = std.array_list.Managed([]const u8).init(arena);
try cflags.append("-I"); try cflags.append("-I");
try cflags.append(tsan_include_path); try cflags.append(tsan_include_path);
@ -163,7 +163,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
.x86_64 => "tsan_rtl_amd64.S", .x86_64 => "tsan_rtl_amd64.S",
else => return error.TSANUnsupportedCPUArchitecture, else => return error.TSANUnsupportedCPUArchitecture,
}; };
var cflags = std.ArrayList([]const u8).init(arena); var cflags = std.array_list.Managed([]const u8).init(arena);
try cflags.append("-I"); try cflags.append("-I");
try cflags.append(tsan_include_path); try cflags.append(tsan_include_path);
@ -182,7 +182,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
"libtsan", "sanitizer_common", "libtsan", "sanitizer_common",
}); });
for (sanitizer_common_sources) |common_src| { for (sanitizer_common_sources) |common_src| {
var cflags = std.ArrayList([]const u8).init(arena); var cflags = std.array_list.Managed([]const u8).init(arena);
try cflags.append("-I"); try cflags.append("-I");
try cflags.append(sanitizer_common_include_path); try cflags.append(sanitizer_common_include_path);
@ -206,7 +206,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
&sanitizer_nolibc_sources; &sanitizer_nolibc_sources;
try c_source_files.ensureUnusedCapacity(to_c_or_not_to_c_sources.len); try c_source_files.ensureUnusedCapacity(to_c_or_not_to_c_sources.len);
for (to_c_or_not_to_c_sources) |c_src| { for (to_c_or_not_to_c_sources) |c_src| {
var cflags = std.ArrayList([]const u8).init(arena); var cflags = std.array_list.Managed([]const u8).init(arena);
try cflags.append("-I"); try cflags.append("-I");
try cflags.append(sanitizer_common_include_path); try cflags.append(sanitizer_common_include_path);
@ -226,7 +226,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
try c_source_files.ensureUnusedCapacity(sanitizer_symbolizer_sources.len); try c_source_files.ensureUnusedCapacity(sanitizer_symbolizer_sources.len);
for (sanitizer_symbolizer_sources) |c_src| { for (sanitizer_symbolizer_sources) |c_src| {
var cflags = std.ArrayList([]const u8).init(arena); var cflags = std.array_list.Managed([]const u8).init(arena);
try cflags.append("-I"); try cflags.append("-I");
try cflags.append(tsan_include_path); try cflags.append(tsan_include_path);
@ -246,7 +246,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
try c_source_files.ensureUnusedCapacity(interception_sources.len); try c_source_files.ensureUnusedCapacity(interception_sources.len);
for (interception_sources) |c_src| { for (interception_sources) |c_src| {
var cflags = std.ArrayList([]const u8).init(arena); var cflags = std.array_list.Managed([]const u8).init(arena);
try cflags.append("-I"); try cflags.append("-I");
try cflags.append(interception_include_path); try cflags.append(interception_include_path);
@ -323,7 +323,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
comp.tsan_lib = crt_file; comp.tsan_lib = crt_file;
} }
fn addCcArgs(target: *const std.Target, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void { fn addCcArgs(target: *const std.Target, args: *std.array_list.Managed([]const u8)) error{OutOfMemory}!void {
try args.appendSlice(&[_][]const u8{ try args.appendSlice(&[_][]const u8{
"-nostdinc++", "-nostdinc++",
"-fvisibility=hidden", "-fvisibility=hidden",

View File

@ -87,7 +87,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
const root_name = "unwind"; const root_name = "unwind";
var c_source_files: [unwind_src_list.len]Compilation.CSourceFile = undefined; var c_source_files: [unwind_src_list.len]Compilation.CSourceFile = undefined;
for (unwind_src_list, 0..) |unwind_src, i| { for (unwind_src_list, 0..) |unwind_src, i| {
var cflags = std.ArrayList([]const u8).init(arena); var cflags = std.array_list.Managed([]const u8).init(arena);
switch (Compilation.classifyFileExt(unwind_src)) { switch (Compilation.classifyFileExt(unwind_src)) {
.c => { .c => {

View File

@ -33,7 +33,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
switch (crt_file) { switch (crt_file) {
.crt2_o => { .crt2_o => {
var args = std.ArrayList([]const u8).init(arena); var args = std.array_list.Managed([]const u8).init(arena);
try addCrtCcArgs(comp, arena, &args); try addCrtCcArgs(comp, arena, &args);
if (comp.mingw_unicode_entry_point) { if (comp.mingw_unicode_entry_point) {
try args.appendSlice(&.{ "-DUNICODE", "-D_UNICODE" }); try args.appendSlice(&.{ "-DUNICODE", "-D_UNICODE" });
@ -53,7 +53,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
}, },
.dllcrt2_o => { .dllcrt2_o => {
var args = std.ArrayList([]const u8).init(arena); var args = std.array_list.Managed([]const u8).init(arena);
try addCrtCcArgs(comp, arena, &args); try addCrtCcArgs(comp, arena, &args);
var files = [_]Compilation.CSourceFile{ var files = [_]Compilation.CSourceFile{
.{ .{
@ -70,10 +70,10 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
}, },
.libmingw32_lib => { .libmingw32_lib => {
var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena); var c_source_files = std.array_list.Managed(Compilation.CSourceFile).init(arena);
{ {
var crt_args = std.ArrayList([]const u8).init(arena); var crt_args = std.array_list.Managed([]const u8).init(arena);
try addCrtCcArgs(comp, arena, &crt_args); try addCrtCcArgs(comp, arena, &crt_args);
for (mingw32_generic_src) |dep| { for (mingw32_generic_src) |dep| {
@ -150,7 +150,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
} }
{ {
var winpthreads_args = std.ArrayList([]const u8).init(arena); var winpthreads_args = std.array_list.Managed([]const u8).init(arena);
try addCcArgs(comp, arena, &winpthreads_args); try addCcArgs(comp, arena, &winpthreads_args);
try winpthreads_args.appendSlice(&[_][]const u8{ try winpthreads_args.appendSlice(&[_][]const u8{
"-DIN_WINPTHREAD", "-DIN_WINPTHREAD",
@ -186,7 +186,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
fn addCcArgs( fn addCcArgs(
comp: *Compilation, comp: *Compilation,
arena: Allocator, arena: Allocator,
args: *std.ArrayList([]const u8), args: *std.array_list.Managed([]const u8),
) error{OutOfMemory}!void { ) error{OutOfMemory}!void {
try args.appendSlice(&[_][]const u8{ try args.appendSlice(&[_][]const u8{
"-std=gnu11", "-std=gnu11",
@ -200,7 +200,7 @@ fn addCcArgs(
fn addCrtCcArgs( fn addCrtCcArgs(
comp: *Compilation, comp: *Compilation,
arena: Allocator, arena: Allocator,
args: *std.ArrayList([]const u8), args: *std.array_list.Managed([]const u8),
) error{OutOfMemory}!void { ) error{OutOfMemory}!void {
try addCcArgs(comp, arena, args); try addCcArgs(comp, arena, args);
@ -401,7 +401,7 @@ fn findDef(
else => unreachable, else => unreachable,
}; };
var override_path = std.ArrayList(u8).init(allocator); var override_path = std.array_list.Managed(u8).init(allocator);
defer override_path.deinit(); defer override_path.deinit();
const s = path.sep_str; const s = path.sep_str;

Some files were not shown because too many files have changed in this diff Show More