From 088955536012d1f693c24f58917730da83d52d16 Mon Sep 17 00:00:00 2001 From: "James K. Lowden" <jklowden@symas.com> Date: Thu, 25 Apr 2024 10:18:43 -0400 Subject: [PATCH] reduce dts::regex memory overhead --- gcc/cobol/dts.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/cobol/dts.h b/gcc/cobol/dts.h index 918ed08e1ff9..893ef87502b0 100644 --- a/gcc/cobol/dts.h +++ b/gcc/cobol/dts.h @@ -24,6 +24,8 @@ #include <err.h> #include <regex.h> +void yyerrorv( const char fmt[], ... ); + namespace dts { class csub_match : public regmatch_t { const char *input; @@ -70,12 +72,16 @@ namespace dts { throw std::logic_error(msg); #else pattern = NULL; - warnx("error: %s", msg); + yyerrorv("error: %s", msg); #endif } } + ~regex() { regfree(this); } + size_t size() const { return nsubexpr; } bool ready() const { return pattern != NULL; } + private: + regex( const regex& ) {} }; inline bool regex_search( const char input[], const char *eoinput, -- GitLab