| ... | @@ -251,8 +251,8 @@ pub fn flushModule(self: *C, comp: *Compilation) !void { | ... | @@ -251,8 +251,8 @@ pub fn flushModule(self: *C, comp: *Compilation) !void { |
| 251 | var f: Flush = .{}; | 251 | var f: Flush = .{}; |
| 252 | defer f.deinit(gpa); | 252 | defer f.deinit(gpa); |
| 253 | | 253 | |
| 254 | // This is at least enough until we get to the function bodies without error handling. | 254 | // Covers zig.h and err_typedef_item. |
| 255 | try f.all_buffers.ensureTotalCapacity(gpa, self.decl_table.count() + 2); | 255 | try f.all_buffers.ensureUnusedCapacity(gpa, 2); |
| 256 | | 256 | |
| 257 | f.all_buffers.appendAssumeCapacity(.{ | 257 | f.all_buffers.appendAssumeCapacity(.{ |
| 258 | .iov_base = zig_h, | 258 | .iov_base = zig_h, |
| ... | @@ -261,7 +261,8 @@ pub fn flushModule(self: *C, comp: *Compilation) !void { | ... | @@ -261,7 +261,8 @@ pub fn flushModule(self: *C, comp: *Compilation) !void { |
| 261 | f.file_size += zig_h.len; | 261 | f.file_size += zig_h.len; |
| 262 | | 262 | |
| 263 | const err_typedef_writer = f.err_typedef_buf.writer(gpa); | 263 | const err_typedef_writer = f.err_typedef_buf.writer(gpa); |
| 264 | const err_typedef_item = f.all_buffers.addOneAssumeCapacity(); | 264 | const err_typedef_index = f.all_buffers.items.len; |
| | 265 | f.all_buffers.items.len += 1; |
| 265 | | 266 | |
| 266 | render_errors: { | 267 | render_errors: { |
| 267 | if (module.global_error_set.size == 0) break :render_errors; | 268 | if (module.global_error_set.size == 0) break :render_errors; |
| ... | @@ -291,7 +292,7 @@ pub fn flushModule(self: *C, comp: *Compilation) !void { | ... | @@ -291,7 +292,7 @@ pub fn flushModule(self: *C, comp: *Compilation) !void { |
| 291 | try flushDecl(self, &f, decl); | 292 | try flushDecl(self, &f, decl); |
| 292 | } | 293 | } |
| 293 | | 294 | |
| 294 | err_typedef_item.* = .{ | 295 | f.all_buffers.items[err_typedef_index] = .{ |
| 295 | .iov_base = f.err_typedef_buf.items.ptr, | 296 | .iov_base = f.err_typedef_buf.items.ptr, |
| 296 | .iov_len = f.err_typedef_buf.items.len, | 297 | .iov_len = f.err_typedef_buf.items.len, |
| 297 | }; | 298 | }; |
| ... | @@ -371,7 +372,7 @@ fn flushDecl(self: *C, f: *Flush, decl: *const Module.Decl) FlushDeclError!void | ... | @@ -371,7 +372,7 @@ fn flushDecl(self: *C, f: *Flush, decl: *const Module.Decl) FlushDeclError!void |
| 371 | } | 372 | } |
| 372 | } | 373 | } |
| 373 | const buf = decl_block.fwd_decl.items; | 374 | const buf = decl_block.fwd_decl.items; |
| 374 | f.all_buffers.appendAssumeCapacity(.{ | 375 | try f.all_buffers.append(gpa, .{ |
| 375 | .iov_base = buf.ptr, | 376 | .iov_base = buf.ptr, |
| 376 | .iov_len = buf.len, | 377 | .iov_len = buf.len, |
| 377 | }); | 378 | }); |
| ... | @@ -381,7 +382,7 @@ fn flushDecl(self: *C, f: *Flush, decl: *const Module.Decl) FlushDeclError!void | ... | @@ -381,7 +382,7 @@ fn flushDecl(self: *C, f: *Flush, decl: *const Module.Decl) FlushDeclError!void |
| 381 | f.fn_count += 1; | 382 | f.fn_count += 1; |
| 382 | } else if (decl_block.code.items.len != 0) { | 383 | } else if (decl_block.code.items.len != 0) { |
| 383 | const buf = decl_block.code.items; | 384 | const buf = decl_block.code.items; |
| 384 | f.all_buffers.appendAssumeCapacity(.{ | 385 | try f.all_buffers.append(gpa, .{ |
| 385 | .iov_base = buf.ptr, | 386 | .iov_base = buf.ptr, |
| 386 | .iov_len = buf.len, | 387 | .iov_len = buf.len, |
| 387 | }); | 388 | }); |