Browse Source

Attempt to clean up memory (and processes better)

Luna Stadler 4 years ago
parent
commit
26448ca2c1
1 changed files with 8 additions and 5 deletions
  1. 8 5
      zig/sdl/hello_sdl.zig

+ 8 - 5
zig/sdl/hello_sdl.zig

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