aboutsummaryrefslogtreecommitdiff
path: root/src/include/fe_utils
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2019-07-30 10:54:48 +0900
committerMichael Paquier <michael@paquier.xyz>2019-07-30 10:54:48 +0900
commit04cf0bfc90dfae89a794d2bdd88fe3b8e313798e (patch)
treefbd6a9d2fab669afac82ba65ee9690cebeada45e /src/include/fe_utils
parent3420851a2c2d2ac49b8ba53ccec5d02aa1e6a272 (diff)
downloadpostgresql-04cf0bfc90dfae89a794d2bdd88fe3b8e313798e.tar.gz
postgresql-04cf0bfc90dfae89a794d2bdd88fe3b8e313798e.zip
Fix memory leak coming from simple lists built in reindexdb
When building a list of relations for a parallel processing of a schema or a database (or just a single-entry list for the non-parallel case with the database name), the list is allocated and built on-the-fly for each database processed, leaking after one database-level reindex is done. This accumulates leaks when processing all databases, and could become a visible issue with thousands of relations. This is fixed by introducing a new routine in simple_list.c to free all the elements in a simple list made of strings or OIDs. The header of the list may be using a variable declaration or an allocated pointer, so we don't have a routine to free this part to keep the interface simple. Per report from coverity for an issue introduced by 5ab892c, and valgrind complains about the leak as well. The idea to introduce a new routine in simple_list.c is from Tom Lane. Author: Michael Paquier Reviewed-by: Tom Lane
Diffstat (limited to 'src/include/fe_utils')
-rw-r--r--src/include/fe_utils/simple_list.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/include/fe_utils/simple_list.h b/src/include/fe_utils/simple_list.h
index 8a95cbb3a85..75738becf42 100644
--- a/src/include/fe_utils/simple_list.h
+++ b/src/include/fe_utils/simple_list.h
@@ -46,9 +46,11 @@ typedef struct SimpleStringList
extern void simple_oid_list_append(SimpleOidList *list, Oid val);
extern bool simple_oid_list_member(SimpleOidList *list, Oid val);
+extern void simple_oid_list_destroy(SimpleOidList *list);
extern void simple_string_list_append(SimpleStringList *list, const char *val);
extern bool simple_string_list_member(SimpleStringList *list, const char *val);
+extern void simple_string_list_destroy(SimpleStringList *list);
extern const char *simple_string_list_not_touched(SimpleStringList *list);