aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_backup_tar.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2022-09-12 08:31:56 +0200
committerPeter Eisentraut <peter@eisentraut.org>2022-09-12 08:45:03 +0200
commit5015e1e1b58f81a036e4ad16291ef4b3bb7a596c (patch)
tree86ee608e961dc830e733c534db089f1e45706414 /src/bin/pg_dump/pg_backup_tar.c
parent2016055a92f26d648aba9f66d26cc0bcd1619eff (diff)
downloadpostgresql-5015e1e1b58f81a036e4ad16291ef4b3bb7a596c.tar.gz
postgresql-5015e1e1b58f81a036e4ad16291ef4b3bb7a596c.zip
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/bin/pg_dump/pg_backup_tar.c')
-rw-r--r--src/bin/pg_dump/pg_backup_tar.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
index bfc49b66d2c..7960b81c0e6 100644
--- a/src/bin/pg_dump/pg_backup_tar.c
+++ b/src/bin/pg_dump/pg_backup_tar.c
@@ -151,7 +151,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
/*
* Set up some special context used in compressing data.
*/
- ctx = (lclContext *) pg_malloc0(sizeof(lclContext));
+ ctx = pg_malloc0_object(lclContext);
AH->formatData = (void *) ctx;
ctx->filePos = 0;
ctx->isSpecialScript = 0;
@@ -240,7 +240,7 @@ _ArchiveEntry(ArchiveHandle *AH, TocEntry *te)
lclTocEntry *ctx;
char fn[K_STD_BUF_SIZE];
- ctx = (lclTocEntry *) pg_malloc0(sizeof(lclTocEntry));
+ ctx = pg_malloc0_object(lclTocEntry);
if (te->dataDumper != NULL)
{
snprintf(fn, sizeof(fn), "%d.dat", te->dumpId);
@@ -272,7 +272,7 @@ _ReadExtraToc(ArchiveHandle *AH, TocEntry *te)
if (ctx == NULL)
{
- ctx = (lclTocEntry *) pg_malloc0(sizeof(lclTocEntry));
+ ctx = pg_malloc0_object(lclTocEntry);
te->formatData = (void *) ctx;
}
@@ -337,7 +337,7 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
{
int old_umask;
- tm = pg_malloc0(sizeof(TAR_MEMBER));
+ tm = pg_malloc0_object(TAR_MEMBER);
/*
* POSIX does not require, but permits, tmpfile() to restrict file
@@ -1052,7 +1052,7 @@ static TAR_MEMBER *
_tarPositionTo(ArchiveHandle *AH, const char *filename)
{
lclContext *ctx = (lclContext *) AH->formatData;
- TAR_MEMBER *th = pg_malloc0(sizeof(TAR_MEMBER));
+ TAR_MEMBER *th = pg_malloc0_object(TAR_MEMBER);
char c;
char header[TAR_BLOCK_SIZE];
size_t i,