#How to free Exec result?

1 messages · Page 1 of 1 (latest)

humble cosmos
#

std.ChildProcess.exec returns a result which includes owned slices. and I get a memory leak detected because of it.
How am supposed to free stdout and stderr owned slices of that?

opal meteor
#

you'd free with the same allocator you provided

#

so if you used allocator allocator in exec you'd free the result.stdout/stderr with that allocator

humble cosmos
#

oh yeaa, is this fine?

    allocator.free(result.stdout);
    allocator.free(result.stderr);
opal meteor
#

yep!

humble cosmos
#

I think that ExecResult should have a deinit method, no?

#

for easier cleanup

opal meteor
#

you might want to put that all in a defer {} so you only free at the end but that code is valid

#

eh maybe