v1-0006-seg-Simplify-flex-scan-buffer-management.patch
text/plain
Filename: v1-0006-seg-Simplify-flex-scan-buffer-management.patch
Type: text/plain
Part: 5
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v1-0006
Subject: seg: Simplify flex scan buffer management
| File | + | − |
|---|---|---|
| contrib/seg/segscan.l | 1 | 12 |
From 9f08aeaf4a5597065ff609a35b33f5cdb4904a0d Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Mon, 2 Dec 2024 10:35:37 +0100
Subject: [PATCH v1 06/19] 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