0001-clarify-palloc-comment-on-quote_literal_cstr.patch
text/x-patch
Filename: 0001-clarify-palloc-comment-on-quote_literal_cstr.patch
Type: text/x-patch
Part: 0
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 0001
Subject: clarify palloc comment on quote_literal_cstr
| File | + | − |
|---|---|---|
| src/backend/utils/adt/quote.c | 5 | 1 |
From 1eb0a72ea819ee9217d84abb8112e72bf0df61d8 Mon Sep 17 00:00:00 2001 From: steve-chavez <stevechavezast@gmail.com> Date: Sun, 6 Apr 2025 12:33:55 -0500 Subject: [PATCH] clarify palloc comment on quote_literal_cstr --- src/backend/utils/adt/quote.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/adt/quote.c b/src/backend/utils/adt/quote.c index 677efb93e8d..4b9c52e6d9e 100644 --- a/src/backend/utils/adt/quote.c +++ b/src/backend/utils/adt/quote.c @@ -108,7 +108,11 @@ quote_literal_cstr(const char *rawstr) len = strlen(rawstr); /* We make a worst-case result area; wasting a little space is OK */ - result = palloc(len * 2 + 3 + 1); + result = palloc( + (len * 2) /* worst-case doubling for every character if each one is a quote */ + + 3 /* two outer quotes + possibly 'E' if needed */ + + 1 /* null terminator */ + ); newlen = quote_literal_internal(result, rawstr, len); result[newlen] = '\0'; -- 2.40.1