| ... | @@ -309,15 +309,13 @@ pub fn make( | ... | @@ -309,15 +309,13 @@ pub fn make( |
| 309 | } | 309 | } |
| 310 | } | 310 | } |
| 311 | | 311 | |
| 312 | pub fn deinit(step: *Step, gpa: Allocator) void { | 312 | pub fn deinit(step: *Step, gpa: Allocator, io: Io) void { |
| 313 | step.clearResultStderr(gpa); | 313 | step.clearResultStderr(gpa); |
| 314 | step.clearFailedCommand(gpa); | 314 | step.clearFailedCommand(gpa); |
| 315 | step.clearErrorBundle(gpa); | 315 | step.clearErrorBundle(gpa); |
| 316 | step.inputs.deinit(gpa); | 316 | step.inputs.deinit(gpa); |
| 317 | if (step.getZigProcess()) |zp| gpa.destroy(zp); | | |
| 318 | switch (step.extended) { | 317 | switch (step.extended) { |
| 319 | .check_file, | 318 | .check_file, |
| 320 | .compile, | | |
| 321 | .config_header, | 319 | .config_header, |
| 322 | .fail, | 320 | .fail, |
| 323 | .find_program, | 321 | .find_program, |
| ... | @@ -331,7 +329,7 @@ pub fn deinit(step: *Step, gpa: Allocator) void { | ... | @@ -331,7 +329,7 @@ pub fn deinit(step: *Step, gpa: Allocator) void { |
| 331 | .update_source_files, | 329 | .update_source_files, |
| 332 | .write_file, | 330 | .write_file, |
| 333 | => {}, | 331 | => {}, |
| 334 | inline .fmt, .run => |*extended| extended.deinit(gpa), | 332 | inline .compile, .fmt, .run => |*extended| extended.deinit(gpa, io), |
| 335 | } | 333 | } |
| 336 | step.* = undefined; | 334 | step.* = undefined; |
| 337 | } | 335 | } |
| ... | @@ -455,6 +453,11 @@ pub const ZigProcess = struct { | ... | @@ -455,6 +453,11 @@ pub const ZigProcess = struct { |
| 455 | zp.multi_reader.deinit(); | 453 | zp.multi_reader.deinit(); |
| 456 | zp.* = undefined; | 454 | zp.* = undefined; |
| 457 | } | 455 | } |
| | 456 | |
| | 457 | pub fn destroy(zp: *ZigProcess, gpa: Allocator, io: Io) void { |
| | 458 | zp.deinit(io); |
| | 459 | gpa.destroy(zp); |
| | 460 | } |
| 458 | }; | 461 | }; |
| 459 | | 462 | |
| 460 | /// Assumes that argv contains `--listen=-` and that the process being spawned | 463 | /// Assumes that argv contains `--listen=-` and that the process being spawned |
| ... | @@ -482,9 +485,8 @@ pub fn evalZigProcess( | ... | @@ -482,9 +485,8 @@ pub fn evalZigProcess( |
| 482 | zp.progress_ipc_index = null; | 485 | zp.progress_ipc_index = null; |
| 483 | var exited = false; | 486 | var exited = false; |
| 484 | defer if (exited) { | 487 | defer if (exited) { |
| 485 | s.extended.compile.zig_process = null; | 488 | s.clearZigProcess(); |
| 486 | zp.deinit(io); | 489 | zp.destroy(gpa, io); |
| 487 | gpa.destroy(zp); | | |
| 488 | } else zp.saveState(prog_node); | 490 | } else zp.saveState(prog_node); |
| 489 | const result = zigProcessUpdate(step_index, maker, zp, watch) catch |err| switch (err) { | 491 | const result = zigProcessUpdate(step_index, maker, zp, watch) catch |err| switch (err) { |
| 490 | error.BrokenPipe, error.EndOfStream => |reason| { | 492 | error.BrokenPipe, error.EndOfStream => |reason| { |
| ... | @@ -730,6 +732,13 @@ pub fn getZigProcess(s: *Step) ?*ZigProcess { | ... | @@ -730,6 +732,13 @@ pub fn getZigProcess(s: *Step) ?*ZigProcess { |
| 730 | }; | 732 | }; |
| 731 | } | 733 | } |
| 732 | | 734 | |
| | 735 | fn clearZigProcess(s: *Step) void { |
| | 736 | (switch (s.extended) { |
| | 737 | .compile => |*compile| &compile.zig_process, |
| | 738 | else => return, |
| | 739 | }).* = null; |
| | 740 | } |
| | 741 | |
| 733 | fn sendMessage(io: Io, file: Io.File, tag: std.zig.Client.Message.Tag) !void { | 742 | fn sendMessage(io: Io, file: Io.File, tag: std.zig.Client.Message.Tag) !void { |
| 734 | const header: std.zig.Client.Message.Header = .{ | 743 | const header: std.zig.Client.Message.Header = .{ |
| 735 | .tag = tag, | 744 | .tag = tag, |