commit c7b59fc8041d67a27167ba1a624551081e4b4e7b
parent 035644f92d372ccc06112808afb48b750b9dd3dd
Author: Lou Woell <lou.woell@posteo.de>
Date: Tue, 17 Feb 2026 13:05:06 +0100
[find-refs] fix: memory leak, whitespace
Diffstat:
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/cmd/harehelper/find_refs.ha b/cmd/harehelper/find_refs.ha
@@ -176,9 +176,9 @@ fn next_ref (lex: *lex::lexer) (xref | done | error) = {
fn scan_file (path: str, id: ast::ident) ([]xref | error) = {
const input = os::open(path)?;
-defer io::close(input)!;
+ defer io::close(input)!;
-const sc = bufio::newscanner(input);
+ const sc = bufio::newscanner(input);
defer bufio::finish(&sc);
const lexer = lex::init(&sc, path, lex::flag::COMMENTS);
@@ -227,7 +227,7 @@ const sc = bufio::newscanner(input);
};
let res: []xref = [];
- for (let ref => next_ref(&lexer)?) {
+ for :ref (let ref => next_ref(&lexer)?) {
for (let i .. names) {
if (ident_in(i, ref.name)) {
ref.context = match (get_line(lexer.in.src, &ref)) {
@@ -238,8 +238,11 @@ const sc = bufio::newscanner(input);
};
append(res, ref)!;
+ continue :ref;
};
};
+
+ finish_xref(&ref);
};
return res;