hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 0c34ea970d66d2d4f3da7aac4a984abae7d90e0d
parent d71de84c03a239ae23a384c08d5135def69016d3
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue,  2 Feb 2021 21:38:28 -0500

fdstream: free name on close

Diffstat:
Mos/+linux/fdstream.ha | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/os/+linux/fdstream.ha b/os/+linux/fdstream.ha @@ -31,6 +31,7 @@ fn is_fdstream(s: *io::stream) bool = { return s.reader == &fd_read || s.writer == &fd_write || s.closer == &fd_close + || s.closer == &fd_close_static || s.copier == &fd_copy; }; @@ -49,7 +50,7 @@ fn static_fdopen(fd: int, name: str, stream: *fd_stream) *io::stream = { name = name, reader = &fd_read, writer = &fd_write, - closer = &fd_close, + closer = &fd_close_static, }; stream.fd = fd; return &stream.stream; @@ -85,6 +86,13 @@ fn fd_write(s: *io::stream, buf: const []u8) (size | io::error) = { fn fd_close(s: *io::stream) void = { let stream = s: *fd_stream; rt::close(stream.fd); + free(s.name); + free(stream); +}; + +fn fd_close_static(s: *io::stream) void = { + let stream = s: *fd_stream; + rt::close(stream.fd); free(stream); };