summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorPeter Eisentraut2022-09-12 06:31:56 +0000
committerPeter Eisentraut2022-09-12 06:45:03 +0000
commit5015e1e1b58f81a036e4ad16291ef4b3bb7a596c (patch)
tree86ee608e961dc830e733c534db089f1e45706414 /src/common
parent2016055a92f26d648aba9f66d26cc0bcd1619eff (diff)
Assorted examples of expanded type-safer palloc/pg_malloc API
This adds some uses of the new palloc/pg_malloc variants here and there as a demonstration and test. This is kept separate from the actual API patch, since the latter might be backpatched at some point. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/bb755632-2a43-d523-36f8-a1e7a389a907@enterprisedb.com
Diffstat (limited to 'src/common')
-rw-r--r--src/common/config_info.c2
-rw-r--r--src/common/controldata_utils.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/common/config_info.c b/src/common/config_info.c
index aa643b63fe..891a1505cc 100644
--- a/src/common/config_info.c
+++ b/src/common/config_info.c
@@ -39,7 +39,7 @@ get_configdata(const char *my_exec_path, size_t *configdata_len)
/* Adjust this to match the number of items filled below */
*configdata_len = 23;
- configdata = (ConfigData *) palloc(*configdata_len * sizeof(ConfigData));
+ configdata = palloc_array(ConfigData, *configdata_len);
configdata[i].name = pstrdup("BINDIR");
strlcpy(path, my_exec_path, sizeof(path));
diff --git a/src/common/controldata_utils.c b/src/common/controldata_utils.c
index 4c0da6e124..66168543a6 100644
--- a/src/common/controldata_utils.c
+++ b/src/common/controldata_utils.c
@@ -59,7 +59,7 @@ get_controlfile(const char *DataDir, bool *crc_ok_p)
AssertArg(crc_ok_p);
- ControlFile = palloc(sizeof(ControlFileData));
+ ControlFile = palloc_object(ControlFileData);
snprintf(ControlFilePath, MAXPGPATH, "%s/global/pg_control", DataDir);
#ifndef FRONTEND