aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2003-10-08 03:52:32 +0000
committerBruce Momjian <bruce@momjian.us>2003-10-08 03:52:32 +0000
commitbdae05f5d106e215ca84857478716b6ae1cbf967 (patch)
tree079760a8c91311c1d3f9a25bc0d818b4082435f2 /src
parentb8382c26884f4adcf525e0bc7fdf0c671d57b84d (diff)
downloadpostgresql-bdae05f5d106e215ca84857478716b6ae1cbf967.tar.gz
postgresql-bdae05f5d106e215ca84857478716b6ae1cbf967.zip
Use calloc() to allocate empty structures.
Fix pg_restore tar log output bug where Special flag wasn't being initialized; bug seen on XP.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_backup_custom.c6
-rw-r--r--src/bin/pg_dump/pg_backup_files.c8
-rw-r--r--src/bin/pg_dump/pg_backup_tar.c11
-rw-r--r--src/bin/pg_dump/pg_dump.c11
4 files changed, 17 insertions, 19 deletions
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c
index 802b02811f5..8f207a0331f 100644
--- a/src/bin/pg_dump/pg_backup_custom.c
+++ b/src/bin/pg_dump/pg_backup_custom.c
@@ -19,7 +19,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.25 2003/08/04 00:43:27 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.26 2003/10/08 03:52:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -136,7 +136,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
/*
* Set up some special context used in compressing data.
*/
- ctx = (lclContext *) malloc(sizeof(lclContext));
+ ctx = (lclContext *) calloc(1, sizeof(lclContext));
if (ctx == NULL)
die_horribly(AH, modulename, "out of memory\n");
AH->formatData = (void *) ctx;
@@ -253,7 +253,7 @@ _ReadExtraToc(ArchiveHandle *AH, TocEntry *te)
if (ctx == NULL)
{
- ctx = (lclTocEntry *) malloc(sizeof(lclTocEntry));
+ ctx = (lclTocEntry *) calloc(1, sizeof(lclTocEntry));
te->formatData = (void *) ctx;
}
diff --git a/src/bin/pg_dump/pg_backup_files.c b/src/bin/pg_dump/pg_backup_files.c
index 3a4914828a5..b686bc34043 100644
--- a/src/bin/pg_dump/pg_backup_files.c
+++ b/src/bin/pg_dump/pg_backup_files.c
@@ -20,7 +20,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.21 2002/10/25 01:33:17 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.22 2003/10/08 03:52:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -101,7 +101,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
/*
* Set up some special context used in compressing data.
*/
- ctx = (lclContext *) malloc(sizeof(lclContext));
+ ctx = (lclContext *) calloc(1, sizeof(lclContext));
AH->formatData = (void *) ctx;
ctx->filePos = 0;
@@ -167,7 +167,7 @@ _ArchiveEntry(ArchiveHandle *AH, TocEntry *te)
lclTocEntry *ctx;
char fn[K_STD_BUF_SIZE];
- ctx = (lclTocEntry *) malloc(sizeof(lclTocEntry));
+ ctx = (lclTocEntry *) calloc(1, sizeof(lclTocEntry));
if (te->dataDumper)
{
#ifdef HAVE_LIBZ
@@ -206,7 +206,7 @@ _ReadExtraToc(ArchiveHandle *AH, TocEntry *te)
if (ctx == NULL)
{
- ctx = (lclTocEntry *) malloc(sizeof(lclTocEntry));
+ ctx = (lclTocEntry *) calloc(1, sizeof(lclTocEntry));
te->formatData = (void *) ctx;
}
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
index 88e1595787f..8cf9b15e1b8 100644
--- a/src/bin/pg_dump/pg_backup_tar.c
+++ b/src/bin/pg_dump/pg_backup_tar.c
@@ -16,7 +16,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.37 2003/08/04 00:43:27 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.38 2003/10/08 03:52:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -158,10 +158,11 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
/*
* Set up some special context used in compressing data.
*/
- ctx = (lclContext *) malloc(sizeof(lclContext));
+ ctx = (lclContext *) calloc(1, sizeof(lclContext));
AH->formatData = (void *) ctx;
ctx->filePos = 0;
-
+ ctx->isSpecialScript = 0;
+
/* Initialize LO buffering */
AH->lo_buf_size = LOBBUFSIZE;
AH->lo_buf = (void *) malloc(LOBBUFSIZE);
@@ -253,7 +254,7 @@ _ArchiveEntry(ArchiveHandle *AH, TocEntry *te)
lclTocEntry *ctx;
char fn[K_STD_BUF_SIZE];
- ctx = (lclTocEntry *) malloc(sizeof(lclTocEntry));
+ ctx = (lclTocEntry *) calloc(1, sizeof(lclTocEntry));
if (te->dataDumper != NULL)
{
#ifdef HAVE_LIBZ
@@ -292,7 +293,7 @@ _ReadExtraToc(ArchiveHandle *AH, TocEntry *te)
if (ctx == NULL)
{
- ctx = (lclTocEntry *) malloc(sizeof(lclTocEntry));
+ ctx = (lclTocEntry *) calloc(1, sizeof(lclTocEntry));
te->formatData = (void *) ctx;
}
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index a2c5c388e54..e47e4b1ce8f 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -12,7 +12,7 @@
* by PostgreSQL
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.352 2003/09/27 22:10:01 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.353 2003/10/08 03:52:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1078,7 +1078,7 @@ dumpClasses(const TableInfo *tblinfo, const int numTables, Archive *fout,
write_msg(NULL, "preparing to dump the contents of table %s\n",
classname);
- dumpCtx = (DumpContext *) malloc(sizeof(DumpContext));
+ dumpCtx = (DumpContext *) calloc(1, sizeof(DumpContext));
dumpCtx->tblinfo = (TableInfo *) tblinfo;
dumpCtx->tblidx = i;
dumpCtx->oids = oids;
@@ -1938,9 +1938,7 @@ getFuncs(int *numFuncs)
*numFuncs = ntups;
- finfo = (FuncInfo *) malloc(ntups * sizeof(FuncInfo));
-
- memset((char *) finfo, 0, ntups * sizeof(FuncInfo));
+ finfo = (FuncInfo *) calloc(ntups, sizeof(FuncInfo));
i_oid = PQfnumber(res, "oid");
i_proname = PQfnumber(res, "proname");
@@ -2144,8 +2142,7 @@ getTables(int *numTables)
* dumping only one, because we don't yet know which tables might be
* inheritance ancestors of the target table.
*/
- tblinfo = (TableInfo *) malloc(ntups * sizeof(TableInfo));
- memset(tblinfo, 0, ntups * sizeof(TableInfo));
+ tblinfo = (TableInfo *) calloc(ntups, sizeof(TableInfo));
i_reloid = PQfnumber(res, "oid");
i_relname = PQfnumber(res, "relname");