Просмотр исходного кода

Attempt to clean up memory (and processes better)

Luna Stadler лет назад: 4
Родитель
Сommit
26448ca2c1
1 измененных файлов с 8 добавлено и 5 удалено
  1. 8 5
      zig/sdl/hello_sdl.zig

+ 8 - 5
zig/sdl/hello_sdl.zig

@ -153,9 +153,12 @@ const ProcessWithOutput = struct {
153 153
        }
154 154
    }
155 155
156
    fn deinit(self: *ProcessWithOutput) void {
156
    fn deinit(self: *ProcessWithOutput) !void {
157 157
        self.stdout_buf.deinit();
158 158
        self.stderr_buf.deinit();
159
        if (self.is_running()) {
160
            _ = try self.process.kill();
161
        }
159 162
        self.process.deinit();
160 163
    }
161 164
};
@ -189,7 +192,7 @@ const Runner = struct {
189 192
                        return err;
190 193
                    },
191 194
                };
192
                process.deinit();
195
                try process.deinit();
193 196
            }
194 197
        }
195 198
@ -222,9 +225,9 @@ const Runner = struct {
222 225
        return "<no output>";
223 226
    }
224 227
225
    fn deinit(self: *Runner) void {
228
    fn deinit(self: *Runner) !void {
226 229
        if (self.process) |*process| {
227
            process.deinit();
230
            try process.deinit();
228 231
        }
229 232
    }
230 233
};
@ -832,7 +835,7 @@ pub fn main() !void {
832 835
833 836
    // clean up memory and processes
834 837
    for (commands) |*command| {
835
        command.deinit();
838
        try command.deinit();
836 839
    }
837 840
}
838 841