v1-0011-syncrep-parser-Use-palloc-instead-of-malloc-for-f.patch
text/plain
Filename: v1-0011-syncrep-parser-Use-palloc-instead-of-malloc-for-f.patch
Type: text/plain
Part: 10
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-0011
Subject: syncrep parser: Use palloc() instead of malloc() for flex
| File | + | − |
|---|---|---|
| src/backend/replication/syncrep_scanner.l | 30 | 0 |
From f59ae387f2c63019911b15d150b2176050f5e30d 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 11/19] syncrep parser: Use palloc() instead of malloc() for
flex
---
src/backend/replication/syncrep_scanner.l | 30 +++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/src/backend/replication/syncrep_scanner.l b/src/backend/replication/syncrep_scanner.l
index b1edb780502..ac2eecd7804 100644
--- a/src/backend/replication/syncrep_scanner.l
+++ b/src/backend/replication/syncrep_scanner.l
@@ -51,6 +51,9 @@ static StringInfoData xdbuf; /* FIXME */
%option noinput
%option nounput
%option noyywrap
+%option noyyalloc
+%option noyyrealloc
+%option noyyfree
%option warn
%option prefix="syncrep_yy"
@@ -168,3 +171,30 @@ syncrep_scanner_finish(yyscan_t yyscanner)
{
yylex_destroy(yyscanner);
}
+
+/*
+ * Interface functions to make flex use palloc() instead of malloc().
+ * It'd be better to make these static, but flex insists otherwise.
+ */
+
+void *
+yyalloc(yy_size_t size, yyscan_t yyscanner)
+{
+ return palloc(size);
+}
+
+void *
+yyrealloc(void *ptr, yy_size_t size, yyscan_t yyscanner)
+{
+ if (ptr)
+ return repalloc(ptr, size);
+ else
+ return palloc(size);
+}
+
+void
+yyfree(void *ptr, yyscan_t yyscanner)
+{
+ if (ptr)
+ pfree(ptr);
+}
--
2.47.1