authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-10-24 23:07:01+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-10-24 23:07:01+02:00
log680ab55488798be67fd1744f69045b41580def07
treeb3779cd54b2912da4c5a07af2d7ed2c77a12e877
parent935a3b9c757283b4eaaf78b417e34d7d0fbc8737
parentbc2c709e18b72b31b4f65ff6b9b14b9229da491e

Merge pull request 'ArrayList: remove usages of Managed from `std/zig/llvm`, `lib/compiler/Maker`, `docs/wasm/markdown`' (#37385) from Der_Teufel/zig:arraylist-managed into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37385 Reviewed-by: Andrew Kelley <andrew@ziglang.org>

8 files changed, 61 insertions(+), 54 deletions(-)

lib/compiler/Maker.zig+11-8
...@@ -4681,12 +4681,13 @@ test sanitizeExampleName {...@@ -4681,12 +4681,13 @@ test sanitizeExampleName {
4681const Templates = struct {4681const Templates = struct {
4682 zig_lib_directory: Cache.Directory,4682 zig_lib_directory: Cache.Directory,
4683 dir: Io.Dir,4683 dir: Io.Dir,
4684 buffer: std.array_list.Managed(u8),4684 buffer: std.ArrayList(u8),
4685 gpa: Allocator,
46854686
4686 fn deinit(templates: *Templates, io: Io) void {4687 fn deinit(templates: *Templates, io: Io) void {
4687 templates.zig_lib_directory.handle.close(io);4688 templates.zig_lib_directory.handle.close(io);
4688 templates.dir.close(io);4689 templates.dir.close(io);
4689 templates.buffer.deinit();4690 templates.buffer.deinit(templates.gpa);
4690 templates.* = undefined;4691 templates.* = undefined;
4691 }4692 }
46924693
...@@ -4709,29 +4710,30 @@ const Templates = struct {...@@ -4709,29 +4710,30 @@ const Templates = struct {
4709 const contents = templates.dir.readFileAlloc(io, template_path, arena, .limited(max_bytes)) catch |err| {4710 const contents = templates.dir.readFileAlloc(io, template_path, arena, .limited(max_bytes)) catch |err| {
4710 fatal("unable to read template file {q}: {t}", .{ template_path, err });4711 fatal("unable to read template file {q}: {t}", .{ template_path, err });
4711 };4712 };
4713 const gpa = templates.gpa;
4712 templates.buffer.clearRetainingCapacity();4714 templates.buffer.clearRetainingCapacity();
4713 try templates.buffer.ensureUnusedCapacity(contents.len);4715 try templates.buffer.ensureUnusedCapacity(gpa, contents.len);
4714 var i: usize = 0;4716 var i: usize = 0;
4715 while (i < contents.len) {4717 while (i < contents.len) {
4716 if (contents[i] == '_' or contents[i] == '.') {4718 if (contents[i] == '_' or contents[i] == '.') {
4717 // Both '_' and '.' are allowed because depending on the context4719 // Both '_' and '.' are allowed because depending on the context
4718 // one prefix will be valid, while the other might not.4720 // one prefix will be valid, while the other might not.
4719 if (std.mem.startsWith(u8, contents[i + 1 ..], "NAME")) {4721 if (std.mem.startsWith(u8, contents[i + 1 ..], "NAME")) {
4720 try templates.buffer.appendSlice(root_name);4722 try templates.buffer.appendSlice(gpa, root_name);
4721 i += "_NAME".len;4723 i += "_NAME".len;
4722 continue;4724 continue;
4723 } else if (std.mem.startsWith(u8, contents[i + 1 ..], "FINGERPRINT")) {4725 } else if (std.mem.startsWith(u8, contents[i + 1 ..], "FINGERPRINT")) {
4724 try templates.buffer.print("0x{x}", .{fingerprint.int()});4726 try templates.buffer.print(gpa, "0x{x}", .{fingerprint.int()});
4725 i += "_FINGERPRINT".len;4727 i += "_FINGERPRINT".len;
4726 continue;4728 continue;
4727 } else if (std.mem.startsWith(u8, contents[i + 1 ..], "ZIGVER")) {4729 } else if (std.mem.startsWith(u8, contents[i + 1 ..], "ZIGVER")) {
4728 try templates.buffer.appendSlice(builtin.zig_version_string);4730 try templates.buffer.appendSlice(gpa, builtin.zig_version_string);
4729 i += "_ZIGVER".len;4731 i += "_ZIGVER".len;
4730 continue;4732 continue;
4731 }4733 }
4732 }4734 }
47334735
4734 try templates.buffer.append(contents[i]);4736 try templates.buffer.append(gpa, contents[i]);
4735 i += 1;4737 i += 1;
4736 }4738 }
47374739
...@@ -4752,7 +4754,8 @@ const Templates = struct {...@@ -4752,7 +4754,8 @@ const Templates = struct {
4752 return .{4754 return .{
4753 .zig_lib_directory = zig_lib_directory,4755 .zig_lib_directory = zig_lib_directory,
4754 .dir = template_dir,4756 .dir = template_dir,
4755 .buffer = std.array_list.Managed(u8).init(gpa),4757 .buffer = .empty,
4758 .gpa = gpa,
4756 };4759 };
4757 }4760 }
47584761
lib/compiler/Maker/Fetch.zig+6-6
...@@ -1756,11 +1756,11 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash...@@ -1756,11 +1756,11 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash
1756 const root_dir = pkg_path.root_dir.handle;1756 const root_dir = pkg_path.root_dir.handle;
17571757
1758 // Collect all files, recursively, then sort.1758 // Collect all files, recursively, then sort.
1759 var all_files = std.array_list.Managed(*HashedFile).init(gpa);1759 var all_files: std.ArrayList(*HashedFile) = .empty;
1760 defer all_files.deinit();1760 defer all_files.deinit(gpa);
17611761
1762 var deleted_files = std.array_list.Managed(*DeletedFile).init(gpa);1762 var deleted_files: std.ArrayList(*DeletedFile) = .empty;
1763 defer deleted_files.deinit();1763 defer deleted_files.deinit(gpa);
17641764
1765 // Track directories which had any files deleted from them so that empty directories1765 // Track directories which had any files deleted from them so that empty directories
1766 // can be deleted.1766 // can be deleted.
...@@ -1803,7 +1803,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash...@@ -1803,7 +1803,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash
1803 .failure = undefined, // to be populated by the worker1803 .failure = undefined, // to be populated by the worker
1804 };1804 };
1805 group.async(io, workerDeleteFile, .{ io, root_dir, deleted_file });1805 group.async(io, workerDeleteFile, .{ io, root_dir, deleted_file });
1806 try deleted_files.append(deleted_file);1806 try deleted_files.append(gpa, deleted_file);
1807 continue;1807 continue;
1808 }1808 }
18091809
...@@ -1831,7 +1831,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash...@@ -1831,7 +1831,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash
1831 .size = undefined, // to be populated by the worker1831 .size = undefined, // to be populated by the worker
1832 };1832 };
1833 group.async(io, workerHashFile, .{ io, root_dir, hashed_file });1833 group.async(io, workerHashFile, .{ io, root_dir, hashed_file });
1834 try all_files.append(hashed_file);1834 try all_files.append(gpa, hashed_file);
1835 }1835 }
18361836
1837 try group.await(io);1837 try group.await(io);
lib/compiler/Maker/Step/Compile.zig+1-1
...@@ -867,7 +867,7 @@ fn lowerZigArgs(...@@ -867,7 +867,7 @@ fn lowerZigArgs(
867 return step.fail(maker, "failed creating directory {f}: {t}", .{ args_path, err });867 return step.fail(maker, "failed creating directory {f}: {t}", .{ args_path, err });
868868
869 const args_to_escape = zig_args.items[2..];869 const args_to_escape = zig_args.items[2..];
870 var escaped_args = try std.array_list.Managed([]const u8).initCapacity(arena, args_to_escape.len);870 var escaped_args: std.ArrayList([]const u8) = try .initCapacity(arena, args_to_escape.len);
871 arg_blk: for (args_to_escape) |arg| {871 arg_blk: for (args_to_escape) |arg| {
872 for (arg, 0..) |c, arg_idx| {872 for (arg, 0..) |c, arg_idx| {
873 if (c == '\\' or c == '"') {873 if (c == '\\' or c == '"') {
lib/docs/wasm/markdown.zig+3-3
...@@ -1119,9 +1119,9 @@ fn testRender(input: []const u8, expected: []const u8) !void {...@@ -1119,9 +1119,9 @@ fn testRender(input: []const u8, expected: []const u8) !void {
1119 var doc = try parser.endInput();1119 var doc = try parser.endInput();
1120 defer doc.deinit(testing.allocator);1120 defer doc.deinit(testing.allocator);
11211121
1122 var actual = std.array_list.Managed(u8).init(testing.allocator);1122 var actual: std.Io.Writer.Allocating = .init(testing.allocator);
1123 defer actual.deinit();1123 defer actual.deinit();
1124 try doc.render(actual.writer());1124 try doc.render(&actual.writer);
11251125
1126 try testing.expectEqualStrings(expected, actual.items);1126 try testing.expectEqualStrings(expected, actual.written());
1127}1127}
lib/docs/wasm/markdown/Document.zig+2-2
...@@ -160,8 +160,8 @@ pub fn deinit(doc: *Document, allocator: Allocator) void {...@@ -160,8 +160,8 @@ pub fn deinit(doc: *Document, allocator: Allocator) void {
160}160}
161161
162/// Renders a document directly to a writer using the default renderer.162/// Renders a document directly to a writer using the default renderer.
163pub fn render(doc: Document, writer: anytype) @TypeOf(writer).Error!void {163pub fn render(doc: Document, writer: *std.Io.Writer) std.Io.Writer.Error!void {
164 const renderer: Renderer(@TypeOf(writer), void) = .{ .context = {} };164 const renderer: Renderer(void) = .{ .context = {} };
165 try renderer.render(doc, writer);165 try renderer.render(doc, writer);
166}166}
167167
lib/std/zig/llvm/BitcodeReader.zig+16-16
...@@ -60,40 +60,40 @@ pub const Record = struct {...@@ -60,40 +60,40 @@ pub const Record = struct {
60 blob: []const u8,60 blob: []const u8,
6161
62 fn toOwnedAbbrev(record: Record, allocator: std.mem.Allocator) !Abbrev {62 fn toOwnedAbbrev(record: Record, allocator: std.mem.Allocator) !Abbrev {
63 var operands = std.array_list.Managed(Abbrev.Operand).init(allocator);63 var operands: std.ArrayList(Abbrev.Operand) = .empty;
64 defer operands.deinit();64 defer operands.deinit(allocator);
6565
66 assert(record.id == Abbrev.Builtin.define_abbrev.toRecordId());66 assert(record.id == Abbrev.Builtin.define_abbrev.toRecordId());
67 var i: usize = 0;67 var i: usize = 0;
68 while (i < record.operands.len) switch (record.operands[i]) {68 while (i < record.operands.len) switch (record.operands[i]) {
69 Abbrev.Operand.literal_id => {69 Abbrev.Operand.literal_id => {
70 try operands.append(.{ .literal = record.operands[i + 1] });70 try operands.append(allocator, .{ .literal = record.operands[i + 1] });
71 i += 2;71 i += 2;
72 },72 },
73 @backingInt(Abbrev.Operand.Encoding.fixed) => {73 @backingInt(Abbrev.Operand.Encoding.fixed) => {
74 try operands.append(.{ .encoding = .{ .fixed = @intCast(record.operands[i + 1]) } });74 try operands.append(allocator, .{ .encoding = .{ .fixed = @intCast(record.operands[i + 1]) } });
75 i += 2;75 i += 2;
76 },76 },
77 @backingInt(Abbrev.Operand.Encoding.vbr) => {77 @backingInt(Abbrev.Operand.Encoding.vbr) => {
78 try operands.append(.{ .encoding = .{ .vbr = @intCast(record.operands[i + 1]) } });78 try operands.append(allocator, .{ .encoding = .{ .vbr = @intCast(record.operands[i + 1]) } });
79 i += 2;79 i += 2;
80 },80 },
81 @backingInt(Abbrev.Operand.Encoding.array) => {81 @backingInt(Abbrev.Operand.Encoding.array) => {
82 try operands.append(.{ .encoding = .{ .array = 6 } });82 try operands.append(allocator, .{ .encoding = .{ .array = 6 } });
83 i += 1;83 i += 1;
84 },84 },
85 @backingInt(Abbrev.Operand.Encoding.char6) => {85 @backingInt(Abbrev.Operand.Encoding.char6) => {
86 try operands.append(.{ .encoding = .char6 });86 try operands.append(allocator, .{ .encoding = .char6 });
87 i += 1;87 i += 1;
88 },88 },
89 @backingInt(Abbrev.Operand.Encoding.blob) => {89 @backingInt(Abbrev.Operand.Encoding.blob) => {
90 try operands.append(.{ .encoding = .{ .blob = 6 } });90 try operands.append(allocator, .{ .encoding = .{ .blob = 6 } });
91 i += 1;91 i += 1;
92 },92 },
93 else => unreachable,93 else => unreachable,
94 };94 };
9595
96 return .{ .operands = try operands.toOwnedSlice() };96 return .{ .operands = try operands.toOwnedSlice(allocator) };
97 }97 }
98};98};
9999
...@@ -198,8 +198,8 @@ fn nextRecord(bc: *BitcodeReader) !?Record {...@@ -198,8 +198,8 @@ fn nextRecord(bc: *BitcodeReader) !?Record {
198 defer bc.record_arena = record_arena.state;198 defer bc.record_arena = record_arena.state;
199 _ = record_arena.reset(.retain_capacity);199 _ = record_arena.reset(.retain_capacity);
200200
201 var operands = try std.array_list.Managed(u64).initCapacity(record_arena.allocator(), abbrev.operands.len);201 var operands: std.ArrayList(u64) = try .initCapacity(record_arena.allocator(), abbrev.operands.len);
202 var blob = std.array_list.Managed(u8).init(record_arena.allocator());202 var blob: std.ArrayList(u8) = .empty;
203 for (abbrev.operands, 0..) |abbrev_operand, abbrev_operand_i| switch (abbrev_operand) {203 for (abbrev.operands, 0..) |abbrev_operand, abbrev_operand_i| switch (abbrev_operand) {
204 .literal => |value| operands.appendAssumeCapacity(value),204 .literal => |value| operands.appendAssumeCapacity(value),
205 .encoding => |abbrev_encoding| switch (abbrev_encoding) {205 .encoding => |abbrev_encoding| switch (abbrev_encoding) {
...@@ -208,7 +208,7 @@ fn nextRecord(bc: *BitcodeReader) !?Record {...@@ -208,7 +208,7 @@ fn nextRecord(bc: *BitcodeReader) !?Record {
208 .array => |len_width| {208 .array => |len_width| {
209 assert(abbrev_operand_i + 2 == abbrev.operands.len);209 assert(abbrev_operand_i + 2 == abbrev.operands.len);
210 const len: usize = @intCast(try bc.readVbr(u32, len_width));210 const len: usize = @intCast(try bc.readVbr(u32, len_width));
211 try operands.ensureUnusedCapacity(len);211 try operands.ensureUnusedCapacity(record_arena.allocator(), len);
212 for (0..len) |_| switch (abbrev.operands[abbrev.operands.len - 1]) {212 for (0..len) |_| switch (abbrev.operands[abbrev.operands.len - 1]) {
213 .literal => |elem_value| operands.appendAssumeCapacity(elem_value),213 .literal => |elem_value| operands.appendAssumeCapacity(elem_value),
214 .encoding => |elem_encoding| switch (elem_encoding) {214 .encoding => |elem_encoding| switch (elem_encoding) {
...@@ -219,16 +219,16 @@ fn nextRecord(bc: *BitcodeReader) !?Record {...@@ -219,16 +219,16 @@ fn nextRecord(bc: *BitcodeReader) !?Record {
219 },219 },
220 .align_32_bits, .block_len => return error.UnsupportedArrayElement,220 .align_32_bits, .block_len => return error.UnsupportedArrayElement,
221 .abbrev_op => switch (try bc.readFixed(u1, 1)) {221 .abbrev_op => switch (try bc.readFixed(u1, 1)) {
222 1 => try operands.appendSlice(&.{222 1 => try operands.appendSlice(record_arena.allocator(), &.{
223 Abbrev.Operand.literal_id,223 Abbrev.Operand.literal_id,
224 try bc.readVbr(u64, 8),224 try bc.readVbr(u64, 8),
225 }),225 }),
226 0 => {226 0 => {
227 const encoding: Abbrev.Operand.Encoding =227 const encoding: Abbrev.Operand.Encoding =
228 @fromBackingInt(@intCast(try bc.readFixed(u3, 3)));228 @fromBackingInt(@intCast(try bc.readFixed(u3, 3)));
229 try operands.append(@backingInt(encoding));229 try operands.append(record_arena.allocator(), @backingInt(encoding));
230 switch (encoding) {230 switch (encoding) {
231 .fixed, .vbr => try operands.append(try bc.readVbr(u7, 5)),231 .fixed, .vbr => try operands.append(record_arena.allocator(), try bc.readVbr(u7, 5)),
232 .array, .char6, .blob => {},232 .array, .char6, .blob => {},
233 _ => return error.UnsuportedAbbrevEncoding,233 _ => return error.UnsuportedAbbrevEncoding,
234 }234 }
...@@ -243,7 +243,7 @@ fn nextRecord(bc: *BitcodeReader) !?Record {...@@ -243,7 +243,7 @@ fn nextRecord(bc: *BitcodeReader) !?Record {
243 const len = std.math.cast(usize, try bc.readVbr(u32, len_width)) orelse243 const len = std.math.cast(usize, try bc.readVbr(u32, len_width)) orelse
244 return error.Overflow;244 return error.Overflow;
245 bc.align32Bits();245 bc.align32Bits();
246 try bc.readBytes(try blob.addManyAsSlice(len));246 try bc.readBytes(try blob.addManyAsSlice(record_arena.allocator(), len));
247 bc.align32Bits();247 bc.align32Bits();
248 },248 },
249 },249 },
lib/std/zig/llvm/Builder.zig+9-9
...@@ -10505,24 +10505,24 @@ pub fn getIntrinsic(...@@ -10505,24 +10505,24 @@ pub fn getIntrinsic(
1050510505
10506 var attributes: struct {10506 var attributes: struct {
10507 builder: *Builder,10507 builder: *Builder,
10508 list: std.array_list.Managed(Attribute.Index),10508 list: std.ArrayList(Attribute.Index),
1050910509
10510 fn deinit(state: *@This()) void {10510 fn deinit(state: *@This(), gpa: Allocator) void {
10511 state.list.deinit();10511 state.list.deinit(gpa);
10512 state.* = undefined;10512 state.* = undefined;
10513 }10513 }
1051410514
10515 fn get(state: *@This(), attributes: []const Attribute) Allocator.Error!Attributes {10515 fn get(state: *@This(), gpa: Allocator, attributes: []const Attribute) Allocator.Error!Attributes {
10516 try state.list.resize(attributes.len);10516 try state.list.resize(gpa, attributes.len);
10517 for (state.list.items, attributes) |*item, attribute|10517 for (state.list.items, attributes) |*item, attribute|
10518 item.* = try state.builder.attr(attribute);10518 item.* = try state.builder.attr(attribute);
10519 return state.builder.attrs(state.list.items);10519 return state.builder.attrs(state.list.items);
10520 }10520 }
10521 } = .{ .builder = self, .list = std.array_list.Managed(Attribute.Index).init(allocator) };10521 } = .{ .builder = self, .list = .empty };
10522 defer attributes.deinit();10522 defer attributes.deinit(allocator);
1052310523
10524 var overload_index: usize = 0;10524 var overload_index: usize = 0;
10525 function_attributes[FunctionAttributes.function_index] = try attributes.get(signature.attrs);10525 function_attributes[FunctionAttributes.function_index] = try attributes.get(allocator, signature.attrs);
10526 function_attributes[FunctionAttributes.return_index] = .none; // needed for void return10526 function_attributes[FunctionAttributes.return_index] = .none; // needed for void return
10527 for (0.., param_types, signature.params) |param_index, *param_type, signature_param| {10527 for (0.., param_types, signature.params) |param_index, *param_type, signature_param| {
10528 switch (signature_param.kind) {10528 switch (signature_param.kind) {
...@@ -10538,7 +10538,7 @@ pub fn getIntrinsic(...@@ -10538,7 +10538,7 @@ pub fn getIntrinsic(
10538 FunctionAttributes.return_index10538 FunctionAttributes.return_index
10539 else10539 else
10540 FunctionAttributes.params_index + (param_index - signature.ret_len)10540 FunctionAttributes.params_index + (param_index - signature.ret_len)
10541 ] = try attributes.get(signature_param.attrs);10541 ] = try attributes.get(allocator, signature_param.attrs);
10542 }10542 }
10543 assert(overload_index == overload.len);10543 assert(overload_index == overload.len);
10544 for (param_types, signature.params) |*param_type, signature_param| {10544 for (param_types, signature.params) |*param_type, signature_param| {
lib/std/zig/llvm/bitcode_writer.zig+13-9
...@@ -19,7 +19,8 @@ pub fn BitcodeWriter(comptime types: []const type) type {...@@ -19,7 +19,8 @@ pub fn BitcodeWriter(comptime types: []const type) type {
19 return struct {19 return struct {
20 const BcWriter = @This();20 const BcWriter = @This();
2121
22 buffer: std.array_list.Managed(u32),22 buffer: std.ArrayList(u32),
23 allocator: std.mem.Allocator,
23 bit_buffer: u32 = 0,24 bit_buffer: u32 = 0,
24 bit_count: u5 = 0,25 bit_count: u5 = 0,
2526
...@@ -31,18 +32,19 @@ pub fn BitcodeWriter(comptime types: []const type) type {...@@ -31,18 +32,19 @@ pub fn BitcodeWriter(comptime types: []const type) type {
3132
32 pub fn init(allocator: std.mem.Allocator, widths: [types.len]u16) BcWriter {33 pub fn init(allocator: std.mem.Allocator, widths: [types.len]u16) BcWriter {
33 return .{34 return .{
34 .buffer = std.array_list.Managed(u32).init(allocator),35 .buffer = .empty,
36 .allocator = allocator,
35 .widths = widths,37 .widths = widths,
36 };38 };
37 }39 }
3840
39 pub fn deinit(self: BcWriter) void {41 pub fn deinit(self: *BcWriter) void {
40 self.buffer.deinit();42 self.buffer.deinit(self.allocator);
41 }43 }
4244
43 pub fn toOwnedSlice(self: *BcWriter) Error![]const u32 {45 pub fn toOwnedSlice(self: *BcWriter) Error![]const u32 {
44 std.debug.assert(self.bit_count == 0);46 std.debug.assert(self.bit_count == 0);
45 return self.buffer.toOwnedSlice();47 return self.buffer.toOwnedSlice(self.allocator);
46 }48 }
4749
48 pub fn length(self: BcWriter) usize {50 pub fn length(self: BcWriter) usize {
...@@ -53,6 +55,8 @@ pub fn BitcodeWriter(comptime types: []const type) type {...@@ -53,6 +55,8 @@ pub fn BitcodeWriter(comptime types: []const type) type {
53 pub fn writeBits(self: *BcWriter, value: anytype, bits: u16) Error!void {55 pub fn writeBits(self: *BcWriter, value: anytype, bits: u16) Error!void {
54 if (bits == 0) return;56 if (bits == 0) return;
5557
58 const allocator = self.allocator;
59
56 var in_buffer = bufValue(value, 32);60 var in_buffer = bufValue(value, 32);
57 var in_bits = bits;61 var in_bits = bits;
5862
...@@ -68,13 +72,13 @@ pub fn BitcodeWriter(comptime types: []const type) type {...@@ -68,13 +72,13 @@ pub fn BitcodeWriter(comptime types: []const type) type {
68 in_bits -= n;72 in_bits -= n;
6973
70 if (self.bit_count != 0) return;74 if (self.bit_count != 0) return;
71 try self.buffer.append(std.mem.nativeToLittle(u32, self.bit_buffer));75 try self.buffer.append(allocator, std.mem.nativeToLittle(u32, self.bit_buffer));
72 self.bit_buffer = 0;76 self.bit_buffer = 0;
73 }77 }
7478
75 // Write 32-bit chunks of input bits79 // Write 32-bit chunks of input bits
76 while (in_bits >= 32) {80 while (in_bits >= 32) {
77 try self.buffer.append(std.mem.nativeToLittle(u32, @truncate(in_buffer)));81 try self.buffer.append(allocator, std.mem.nativeToLittle(u32, @truncate(in_buffer)));
7882
79 in_buffer >>= 31;83 in_buffer >>= 31;
80 in_buffer >>= 1;84 in_buffer >>= 1;
...@@ -141,7 +145,7 @@ pub fn BitcodeWriter(comptime types: []const type) type {...@@ -141,7 +145,7 @@ pub fn BitcodeWriter(comptime types: []const type) type {
141145
142 pub fn writeBlob(self: *BcWriter, blob: []const u8) Error!void {146 pub fn writeBlob(self: *BcWriter, blob: []const u8) Error!void {
143 const blob_word_size = std.mem.alignForward(usize, blob.len, 4);147 const blob_word_size = std.mem.alignForward(usize, blob.len, 4);
144 try self.buffer.ensureUnusedCapacity(blob_word_size + 1);148 try self.buffer.ensureUnusedCapacity(self.allocator, blob_word_size + 1);
145 self.alignTo32() catch unreachable;149 self.alignTo32() catch unreachable;
146150
147 const slice = self.buffer.addManyAsSliceAssumeCapacity(blob_word_size / 4);151 const slice = self.buffer.addManyAsSliceAssumeCapacity(blob_word_size / 4);
...@@ -153,7 +157,7 @@ pub fn BitcodeWriter(comptime types: []const type) type {...@@ -153,7 +157,7 @@ pub fn BitcodeWriter(comptime types: []const type) type {
153 pub fn alignTo32(self: *BcWriter) Error!void {157 pub fn alignTo32(self: *BcWriter) Error!void {
154 if (self.bit_count == 0) return;158 if (self.bit_count == 0) return;
155159
156 try self.buffer.append(std.mem.nativeToLittle(u32, self.bit_buffer));160 try self.buffer.append(self.allocator, std.mem.nativeToLittle(u32, self.bit_buffer));
157 self.bit_buffer = 0;161 self.bit_buffer = 0;
158 self.bit_count = 0;162 self.bit_count = 0;
159 }163 }