From c93074ba3949a8edbb5917ceefc80fb020822085 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 2 Dec 2024 10:35:37 +0100 Subject: [PATCH v0 06/15] seg: Simplify flex scan buffer management --- contrib/seg/segscan.l | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/contrib/seg/segscan.l b/contrib/seg/segscan.l index 004ac07fae2..2b35cd4e67a 100644 --- a/contrib/seg/segscan.l +++ b/contrib/seg/segscan.l @@ -25,9 +25,6 @@ fprintf_to_ereport(const char *fmt, const char *msg) { ereport(ERROR, (errmsg_internal("%s", msg))); } - -/* Handles to the buffer that the lexer uses internally */ -static char *scanbuf; // FIXME %} %option reentrant @@ -100,7 +97,6 @@ seg_yyerror(SEG *result, struct Node *escontext, yyscan_t yyscanner, const char void seg_scanner_init(const char *str, yyscan_t *yyscannerp) { - Size slen = strlen(str); yyscan_t yyscanner; if (yylex_init(yyscannerp) != 0) @@ -108,13 +104,7 @@ seg_scanner_init(const char *str, yyscan_t *yyscannerp) yyscanner = *yyscannerp; - /* - * Make a scan buffer with special termination needed by flex. - */ - scanbuf = palloc(slen + 2); - memcpy(scanbuf, str, slen); - scanbuf[slen] = scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR; - yy_scan_buffer(scanbuf, slen + 2, yyscanner); + yy_scan_string(str, yyscanner); } @@ -125,7 +115,6 @@ void seg_scanner_finish(yyscan_t yyscanner) { yylex_destroy(yyscanner); - pfree(scanbuf); } /* -- 2.47.1