From: | Yongtao Huang <yongtaoh2022(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Optimize duplicate code and fix memory leak in function fetch_remote_table_info() |
Date: | 2024-01-19 14:42:46 |
Message-ID: | CAOe1Go3fZdwW9UvAtBJCek7YnFa9itPzO102G4mBgVmtY=9o-A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
Attachment | Content-Type | Size |
---|---|---|
0001-Optimize-duplicate-code-and-fix-memory-leak-in-table.patch | application/octet-stream | 2.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Gustafsson | 2024-01-19 14:53:59 | Re: initdb's -c option behaves wrong way? |
Previous Message | Abhijit Menon-Sen | 2024-01-19 14:41:16 | Re: [PATCH] Exponential backoff for auth_delay |