From 3a2583e918bcc805fe860252f8a520fc2f9b26ce Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 18 Jul 2025 00:34:56 +0300 Subject: fixed minor memory leaks of per-state data in teco_machine_main_t * These were leaked e.g. in case of end-of-macro errors, but also in case of syntax highlighting (teco_lexer_style()). I considered to solve this by overwriting more of the end_of_macro_cb, but it didn't turn out to be trivial always. * Considering that the union in teco_machine_main_t saved only 3 machine words of memory, I decided to sacrifice those for more robust memory management. * teco_machine_qregspec_t cannot be directly embedded into teco_machine_main_t due to recursive dependencies with teco_machine_stringbuilding_t. It could now and should perhaps be allocated only once in teco_machine_main_init(), but it would require more refactoring. --- src/lexer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/lexer.c') diff --git a/src/lexer.c b/src/lexer.c index 6bc696f..2f43b76 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -157,7 +157,9 @@ teco_lexer_step(teco_view_t *view, teco_machine_main_t *machine, * The curly braces will be styled like regular commands. * * FIXME: This works only for top-level macro definitions, - * not for embedded definitions. + * not for nested definitions. + * FIXME: The macrodef_machine's end-of-macro callback could be used + * to detect and highlight an error on the closing `}`. * FIXME: This cannot currently be disabled, not even with SCI_SETPROPERTY. * We could only map it to an ED flag or * rewrite the lexer against the ILexer5 interface, which requires C++. -- cgit v1.2.3