[PATCH] clarify palloc comment on quote_literal_cstr

Поиск
Список
Период
Сортировка
От Steve Chavez
Тема [PATCH] clarify palloc comment on quote_literal_cstr
Дата
Msg-id CAGRrpzZ9bToRWS+fAnjxDJrxwZN1QcJ-y1Pn2yg=Hst6rydLtw@mail.gmail.com
обсуждение исходный текст
Ответы Re: [PATCH] clarify palloc comment on quote_literal_cstr
Список pgsql-hackers
Hello hackers,

I found the numbers in `quote_literal_cstr` palloc quite magical. So I've added a comment clarifying what they mean. The change is small:

        /* 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 */
+       );

Best regards,
Steve
Вложения

В списке pgsql-hackers по дате отправления: