Optimize duplicate code and fix memory leak in function fetch_remote_table_info()

Поиск
Список
Период
Сортировка
От Yongtao Huang
Тема Optimize duplicate code and fix memory leak in function fetch_remote_table_info()
Дата
Msg-id CAOe1Go3fZdwW9UvAtBJCek7YnFa9itPzO102G4mBgVmtY=9o-A@mail.gmail.com
обсуждение исходный текст
Ответы Re: Optimize duplicate code and fix memory leak in function fetch_remote_table_info()  (Michael Paquier <michael@paquier.xyz>)
Список pgsql-hackers
This patch fixes two things in the function fetch_remote_table_info().

(1) pfree(pub_names.data) to avoid potential memory leaks.
(2) 2 pieces of code can do the same work,

``` C
foreach(lc, MySubscription->publications)
{
    if (foreach_current_index(lc) > 0)
        appendStringInfoString(&pub_names, ", ");
    appendStringInfoString(&pub_names, quote_literal_cstr(strVal(lfirst(lc))));
}
```
and
``` C
foreach_node(String, pubstr, MySubscription->publications)
{
    char       *pubname = strVal(pubstr);

    if (foreach_current_index(pubstr) > 0)
        appendStringInfoString(&pub_names, ", ");

    appendStringInfoString(&pub_names, quote_literal_cstr(pubname));
}
```
I wanna integrate them into one function `make_pubname_list()` to make the code neater.

Thanks for your time.

Regards

Yongtao Huang
Вложения

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

Предыдущее
От: Abhijit Menon-Sen
Дата:
Сообщение: Re: [PATCH] Exponential backoff for auth_delay
Следующее
От: Daniel Gustafsson
Дата:
Сообщение: Re: initdb's -c option behaves wrong way?