summaryrefslogtreecommitdiffstats
path: root/match.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-04-11 23:38:42 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-04-11 23:38:42 -0700
commitfe1e960389a89f481d46c02aa040fdc762da735f (patch)
treecd973e0ebcb1e72ff8393e5482ad1190aa7089cc /match.c
parent3d7330b827d6e9cc0d9e87edd30388374cb45900 (diff)
downloadtxr-fe1e960389a89f481d46c02aa040fdc762da735f.tar.gz
txr-fe1e960389a89f481d46c02aa040fdc762da735f.tar.bz2
txr-fe1e960389a89f481d46c02aa040fdc762da735f.zip
txr: spurious retention in @(next).
* match.c (mf_file_lazy): New static function. The lazy list is created here and stored directly into the data field of the context structure. Function is marked NOINLINE because on an older system with gcc 4.4.5, it didn't solve the problem. We need the function to have a stack frame so any spurious copies of the linked list go into a frame that disappears when the function returns. (v_next_impl): Use mf_file_lazy instead of mf_file_data. (open_data_source): Also make this function INLINE just in case because it contains calls to lazy_stream_cons.
Diffstat (limited to 'match.c')
-rw-r--r--match.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/match.c b/match.c
index 0c0cbc5c..5a711b1b 100644
--- a/match.c
+++ b/match.c
@@ -2308,6 +2308,19 @@ static match_files_ctx *mf_file_data(match_files_ctx *nc,
return nc;
}
+NOINLINE static match_files_ctx *mf_file_lazy(match_files_ctx *nc,
+ match_files_ctx *c, val file,
+ val stream, val data_lineno)
+{
+ *nc = *c;
+ nc->files = cons(file, c->files);
+ nc->curfile = file;
+ nc->data = lazy_stream_cons(stream);
+ nc->data_lineno = data_lineno;
+ return nc;
+}
+
+
static match_files_ctx *mf_from_ml(match_files_ctx *nc, match_line_ctx *ml)
{
nc->spec = cons(ml->specline, nil);
@@ -2857,8 +2870,8 @@ static val v_next_impl(match_files_ctx *c)
if (stream) {
match_files_ctx cs;
cons_bind (new_bindings, success,
- match_files(mf_file_data(&cs, c, str,
- lazy_stream_cons(stream), one)));
+ match_files(mf_file_lazy(&cs, c, str,
+ stream, one)));
if (success)
return cons(new_bindings,
@@ -4584,7 +4597,7 @@ static val h_assert(match_line_ctx *c)
abort();
}
-static void open_data_source(match_files_ctx *c)
+NOINLINE static void open_data_source(match_files_ctx *c)
{
spec_bind (specline, first_spec, c->spec);
int non_matching_dir = (consp(first_spec) &&