From 99f64dfc687273ca1ef90199b8c6a9addb6578a9 Mon Sep 17 00:00:00 2001 From: steve-chavez Date: Mon, 7 Apr 2025 13:34:55 -0500 Subject: [PATCH] clarify palloc comment on quote_literal_cstr --- src/backend/utils/adt/quote.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/adt/quote.c b/src/backend/utils/adt/quote.c index 677efb93e8d..60bda20606d 100644 --- a/src/backend/utils/adt/quote.c +++ b/src/backend/utils/adt/quote.c @@ -107,7 +107,10 @@ quote_literal_cstr(const char *rawstr) int newlen; len = strlen(rawstr); - /* We make a worst-case result area; wasting a little space is OK */ + /* Allocate memory for worst case result factoring in a. double the + length number of bytes, in case every character is a quote, b. two + bytes for two outer quotes c. extra byte for E' d. one byte for null + terminator. */ result = palloc(len * 2 + 3 + 1); newlen = quote_literal_internal(result, rawstr, len); -- 2.40.1